Reversve Look Up
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all, I've got a bit of a problem that I can't quite work out how to do. Essentially I have a low resolution 3d map and a given value of X and I want to find the maximum value of Z (from the map) for a given value of X. The hard part is that I then want to find the interpolated value of Y for that maximum Z.
Hopefully that makes sense. I made some progress with the code below but it only gives Y in terms of the low resolution map.
x = [0 100 200 300 400 500 600 700 800 900];
y = [0;1;2;3;4;5;6;7;8;9];
test_z = rand(10,10);
given_x = 150;
interp_x = interp2(x,y,test_z,given_x,y);
[max_z c] = max(interp_x);
found_y_value = y(c)
0 Commenti
Risposte (1)
tlawren
il 1 Mag 2012
I'm not sure you can do anymore with your code then what you are currently doing. But, I could be completely wrong. I can suggest a few changes to your code though. You should probably change interp_x to interp_z. The values returned by interp2(x,y,test_z,given_x,y) are interpolated z values, not x values. Also, for simplicity, you can initialize x and y using the following
x = 0:100:900;
y = (0:1:9)'; % or y = (0:9)'; , b/c a step size of 1 is default
You may have known this already though.
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!