extracting 2-d plot from 3d plot

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

답변 (1개)

Star Strider
Star Strider 2017년 3월 22일

0 개 추천

The view function could be what you want.

댓글 수: 8

Mike Lee
Mike Lee 2017년 3월 22일
I want to do some post processing after getting 2-D plot,
for example, if have x,y plot then i want to draw horizontal line(y) and see where it intersect to x. Is this possible?
Thank you
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
Mike Lee 2017년 3월 22일
Dear. Mr.Striderl,
I really appreciate for your help, but I just wanted to make the question more clear. So suppose that I have 2-D plot as shown below, What I want to do is that I want to draw a straight line at solar elevation 60 which is equivalent as (0,60). Then I want to find the points where solar azmiuth intersects with the straight line. I hope this made more clear about my question.
Thanks again,
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
Mike Lee 2017년 3월 23일
Hi,
Sorry, I don't quite get what you meant by subtracting 60. So I have the plot based on data(scatter plot, not connected each other) What do you exactly mean by subtracting?
Thank you
Star Strider
Star Strider 2017년 3월 23일
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
Star Strider 2017년 3월 23일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2017년 3월 22일

댓글:

2017년 3월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by