Filter löschen
Filter löschen

how to fix this error 'interp2'

3 Ansichten (letzte 30 Tage)
BA am 28 Jul. 2022
Bearbeitet: Matt J am 28 Jul. 2022
%identify axes
[x y] = ginput(2);
% preallocate matrices
cog = zeros(size(matrix,3),1);
% 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
scog = (cog - min(cog)) / (max(cog) - min(cog));

Antworten (1)

Matt J
Matt J am 28 Jul. 2022
Because your first argument to interp2 is a matrix while the second is a scalar.
  6 Kommentare
Matt J
Matt J am 28 Jul. 2022
Bearbeitet: Matt J am 28 Jul. 2022
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 am 28 Jul. 2022
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.

Melden Sie sich an, um zu kommentieren.


Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by