Reversve Look Up

조회 수: 3 (최근 30일)
Dan
Dan 2012년 5월 1일
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)

답변 (1개)

tlawren
tlawren 2012년 5월 1일
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by