Reversve Look Up
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
tlawren
on 1 May 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 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!