extracting 2-d plot from 3d plot
Ältere Kommentare anzeigen
Hi,
I have x,y,z plot by using scatter3 function. I would like to see a 2-d plot such as x vs z or y vs z. What is the function that I can use to this?
Thanks
Antworten (1)
Star Strider
am 22 Mär. 2017
0 Stimmen
The view function could be what you want.
8 Kommentare
Mike Lee
am 22 Mär. 2017
Star Strider
am 22 Mär. 2017
My pleasure.
In an (x,y) plot (as I understand it), a horizontal line will intersect the y-axis and never intersect the x-axis. A vertical line will intersect the x-axis and never the y-axis.
You can draw your line in a 3D plot using the plot3 function and the hold function to plot it on the same axes as your scatter3 plot. You have to define it in 3D, so you would have the coordinates of it in at least one dimension be a ones vector.
Example —
x = rand(150, 1);
y = rand(150, 1);
z = rand(150, 1);
figure(1)
scatter3(x, y, z, 'pg', 'MarkerFaceColor','g')
hold on
plot3([0 1], [0.4 0.4], [0.7 0.7], 'LineWidth',2, 'Color','r')
hold off
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
view([0 90]) % Call ‘view’ Function To Set View Angle [Az El]
Mike Lee
am 22 Mär. 2017
Star Strider
am 22 Mär. 2017
That is a completely different question from the one you originally asked!
If you have an equation for the red line (the only one that crosses 60), create an anonymous function from it and then create a second anonymous function that subtracts 60 from it and use the fzero function to find the two intersections.
Post the equation if you have it and want me to help you with it.
If you have the data for the red line (and not an equation), subtract 60 from it, then use this little utility function to find the indices of the zero-crossing:
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
and then use interp1 to find the zero-crossings more precisely.
Both of these are relatively straightforward problems.
Mike Lee
am 23 Mär. 2017
Star Strider
am 23 Mär. 2017
I don’t understand your data or what you want from it.
The idea of subtracting 60 is to create a zero-crossing, since you want the values at 60. Those are much easier to calculate.
Star Strider
am 23 Mär. 2017
It will help significantly if you save your data to a ‘.mat’ file and attach it here. (Use the ‘paperclip’ icon to attach it.)
Also, post (or attach as a ‘.m’ file) the code that you used to load your data and create that plot.
I need your data and code to understand what you are doing. Without that information, I can only guess what you are doing and suggest approaches to solve your problem.
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
