Why am I getting NaN using interp2?
Ältere Kommentare anzeigen
- I have a 450*90 matrix of values
- I want to sample the matrix at 100 random sample points
However, while my interp2 function runs without errors, my output results vector contains NaN values after the 90th index.
The code below results in me getting NaN for points after the 90th index of vals - why, and how do I correct it?
Shouldn't I be able to sample 1 point from the matrix, or 50, or 100, or 1000 points?
Code:
row_vect = 1:450;
col_vect = 1:90;
[X,Y] = meshgrid(col_vect, row_vect);
V = abs(rand(450,90));
Xq = row_vect(1:100);
Yq = randi(89, 1,100);
vals = interp2(X, Y, V, Xq', Yq');
Thanks
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 26 Aug. 2015
2 Stimmen
Your problem is your X not your Y. max(X(:)) is 90 because your first argument to meshgrid() is col_vec which is 1:90
1 Kommentar
macdommy74
am 26 Aug. 2015
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!