how to fix this error 'interp2'
Afficher commentaires plus anciens
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));
Réponses (1)
Matt J
le 28 Juil 2022
0 votes
Because your first argument to interp2 is a matrix while the second is a scalar.
6 commentaires
Matt J
le 28 Juil 2022
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.
Matt J
le 28 Juil 2022
We only need matrix(:,:,1) to trigger the error.
Steven Lord
le 28 Juil 2022
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!