How to solve "Transpose on ND array is not defined. Use PERMUTE instead."

3 次查看(过去 30 天)
lena = double(imread('lena.tif'));
figure(6);
imshow(lena)
y_LenaHalf = double(imread('lena_half.tif'));
figure(7);
imshow(y_LenaHalf)
x2 = 1:256;
xi_2 = 1:(255/511):256;
yi_2 = interp1(x2, y_LenaHalf, xi_2);
yi2_2 = interp1(x2, yi_2.', xi_2).';
figure(8);
imshow(uint8(yi2_2))
SE2 = (lena - yi2_2).^2;
MSE2 = mean(mean(SE2));
I want to enlarge photo 'lena' using interp1, but i got an issue.
Error using .' Transpose on ND array is not defined. Use PERMUTE instead.
Error in week9_lectorial (line 44) yi2_2 = interp1(x2, yi_2.', xi_2).';

回答(1 个)

KSSV
KSSV 2018-5-22
A = rand(2,3,3) ;
A' % throws error
So, you cannot transpose a 3D matrix, striaght away. Check this:
[m,n,p] = size(A) ;
iwant = zeros(n,m,p) ;
for i = 1:p
iwant(:,:,i) = A(:,:,i)' ;
end

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by