How to obtain y value when x and z are given in matlab 3D plots

2 Ansichten (letzte 30 Tage)
Hi,
I have a 3D plot as shown in the attachment. You can see a data point x=0.25, y=2.25, z=0.27599 in the first curve. I want to find the corresponding y point of the second curve, when z=0.27599 and, x=0.50(second curve) for the second curve are given. Similar way I want to find the corresponding y point when z=0.27599 in the third curve and so on.
Your kind help will be greatly appreciated.

Akzeptierte Antwort

Dimuthu Dharshana Arachchige
First, it is suggested to obtain the 2D plot.
Then use this function. InterX
P = InterX([P2S;phiS],[P2S;Y]);
plot(P2S,phiS,P2S,Y,P(1,:),P(2,:),'ro'); grid on;xlabel('P2');ylabel('Phi'); hold on;

Weitere Antworten (1)

Image Analyst
Image Analyst am 1 Jul. 2020
interp1() should do it. Did you try it?
  3 Kommentare
Image Analyst
Image Analyst am 2 Jul. 2020
Well everything requires work but I don't think one single line of code is a huge amount of work, especially compared to downloading some third party function from the File Exchange. Look, here's a demo where I create data and find out the x value where the curve is equal to some specified y values. And you can see it's one single line of code:
% Create function and plot it.
P2 = linspace(0, 4, 8);
Phi = 1 - cos(2 * pi * P2 / 8);
plot(P2, Phi, 'b.-', 'MarkerSize', 20);
grid on;
xlabel('P2', 'FontSize', 20);
ylabel('Phi', 'FontSize', 20);
yline(1.1, 'Color', 'r');
% Now find x when y = 1.1. This is the single line of code you need.
x = interp1(Phi, P2, 1.1)
% Done! Now place a marker and line at that point.
xline(x, 'Color', 'r');
hold on;
plot(x, 1.1, 'rs', 'MarkerSize', 20, 'LineWidth', 2);
After it hits the x= line of code, it puts this in the command window:
x =
2.12839883449814
I mean, it really can't get much easier than that.
Dimuthu Dharshana Arachchige
Thank you. I greatly appreciate your work and it is much more easier than my method. I tried it. These P2 values were collected from some experimetns. My P2 contains Nan values. Therefore, I recieve the following error.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by