function newcoeffs=beremove(handles,coeffs)

ExtTypes=get(handles.popupmenu7,'String');
Type=ExtTypes{get(handles.popupmenu7,'Value')};
ExtLength=str2num(get(handles.edit6,'String'));
sizesets=size(coeffs);
[dimcoeffs,~]=dimsizetype(coeffs{1});
if length(sizesets)==1
    if dimcoeffs==1
        for j=1:sizesets
            cutcoeffs{j}=coeffs{j}(ExtLength:length(coeffs{j})-ExtLength);
            newcoeffs{j}=wextend('1D',Type,cutcoeffs{j},ExtLength);
        end
    elseif dimcoeffs==2
        for j=1:sizesets
            sizecoeffs=size(coeffs{j});
            cutcoeffs{j}=coeffs{j}(ExtLength:sizecoeffs(1)-ExtLength,ExtLength:sizecoeffs(2)-ExtLength);
            newcoeffs{j}=wextend('2D',Type,cutcoeffs{j},ExtLength);
        end
    elseif dimcoeffs==3
        for j=1:sizesets
            sizecoeffs=size(coeffs{j});
            for k=1:sizecoeffs(3)
                slicecoeffs=coeffs{j}(ExtLength:sizecoeffs(1)-ExtLength,ExtLength:sizecoeffs(2)-ExtLength,k);
                newslicecoeffs=wextend('2D',Type,slicecoeffs,ExtLength);
                newcoeffs{j}(:,:,k)=newslicecoeffs;
            end
        end
    end
    
elseif length(sizesets)==2
    if dimcoeffs==1
        for j=1:sizesets(1)
            for m=1:sizesets(2)
                cutcoeffs{j,m}=coeffs{j,m}(ExtLength:length(coeffs{j,m})-ExtLength);
                newcoeffs{j,m}=wextend('1D',Type,cutcoeffs{j,m},ExtLength);
            end
        end
    elseif dimcoeffs==2
        for j=1:sizesets(1)
            for m=1:sizesets(2)
                sizecoeffs=size(coeffs{j,m});
                cutcoeffs{j,m}=coeffs{j,m}(ExtLength:sizecoeffs(1)-ExtLength,ExtLength:sizecoeffs(2)-ExtLength);
                newcoeffs{j,m}=wextend('2D',Type,cutcoeffs{j,m},ExtLength);
            end
        end
    elseif dimcoeffs==3
        for j=1:sizesets(1)
            for m=1:sizesets(2)
                sizecoeffs=size(coeffs{j,m});
                for k=1:sizecoeffs(3)
                    slicecoeffs=coeffs{j,m}(ExtLength:sizecoeffs(1)-ExtLength,ExtLength:sizecoeffs(2)-ExtLength,k);
                    newslicecoeffs=wextend('2D',Type,slicecoeffs,ExtLength);
                    newcoeffs{j,m}(:,:,k)=newslicecoeffs;
                end
            end
        end
    end
end