how to fix this error 'interp2'

imshow(matrix(:,:,1))
%identify axes
[x y] = ginput(2);
% preallocate matrices
cog = zeros(size(matrix,3),1);
%cog
% loop start
for i = 1:size(matrix,3)
I = matrix(:,:,i);
n = ceil(norm([diff(x), diff(y)]));
test = interp2(I, linspace(x(1), x(2),n), linspace(y(1), y(2),n));
cog(i) = sum((1:length(test)).*test')/sum(test);
% loop end
end
scog = (cog - min(cog)) / (max(cog) - min(cog));

답변 (1개)

Matt J
Matt J 2022년 7월 28일

0 개 추천

Because your first argument to interp2 is a matrix while the second is a scalar.

댓글 수: 6

BA
BA 2022년 7월 28일
편집: BA 2022년 7월 28일
it's a typo, but still have the problem. Any suggestions?
Matt J
Matt J 2022년 7월 28일
it's a typo,
You haven't fixed the typo in your post, so we don't know what your current code is. In addition to that, I suggest you provide us the means to run the code, in particular by attaching "matrix" in a .mat file.
BA
BA 2022년 7월 28일
편집: BA 2022년 7월 28일
.mat file is huge one (MRI video)
This is the error I get:
error: =: nonconformant arguments (op1 is 1x1, op2 is 1x28)
Matt J
Matt J 2022년 7월 28일
We only need matrix(:,:,1) to trigger the error.
Matt J
Matt J 2022년 7월 28일
편집: Matt J 2022년 7월 28일
This is the error I get:
That is not what a Matlab error message looks like. As a routine matter, you should copy/paste error output messages in their entirety.
Steven Lord
Steven Lord 2022년 7월 28일
From these questions: 1, 2 it sounds like the poster is using Octave rather than MATLAB. If that's the case, that would explain the difference in the appearance of the error message.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

BA
2022년 7월 28일

편집:

2022년 7월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by