WHEN I AM RUNNING THIS CODE I AM GETTING FOLLOWING ERROR
1 次查看(过去 30 天)
显示 更早的评论
function [p,s] = perdecomp(u)
[ny,nx] = size(u);
u = double(u);
X = 1:nx;
Y = 1:ny;
v = zeros(ny,nx);
v(1,X) = u(1,X)-u(ny,X);
v(ny,X) = -v(1,X);
v(Y,1 ) = v(Y,1 )+u(Y,1)-u(Y,nx);
v(Y,nx) = v(Y,nx)-u(Y,1)+u(Y,nx);
fx = repmat(cos(2.*pi*(X -1)/nx),ny,1);
fy = repmat(cos(2.*pi*(Y'-1)/ny),1,nx);
fx(1,1)=0.; % avoid division by 0 in the line below
s = real(ifft2(fft2(v)*0.5./(2.-fx-fy)));
p = u-s;
Arrays have incompatible sizes for this operation.
Error in perdecomp (line 17)
p = u-s;
0 个评论
采纳的回答
VBBV
2022-7-20
u = rand(1,5) % assume a matrix values
[p,s]= perdecomp(u) % call the function giving input matrix u
function [p,s] = perdecomp(u)
[ny,nx] = size(u);
u = double(u);
X = 1:nx;
Y = 1:ny;
v = zeros(ny,nx);
v(1,X) = u(1,X)-u(ny,X);
v(ny,X) = -v(1,X);
v(Y,1 ) = v(Y,1 )+u(Y,1)-u(Y,nx);
v(Y,nx) = v(Y,nx)-u(Y,1)+u(Y,nx);
fx = repmat(cos(2.*pi*(X -1)/nx),ny,1);
fy = repmat(cos(2.*pi*(Y'-1)/ny),1,nx);
fx(1,1)=0.; % avoid division by 0 in the line below
s = real(ifft2(fft2(v)*0.5./(2.-fx-fy)));
p = u-s;
end
Give input vector when calling function perdecomp
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Encryption / Cryptography 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!