multiple 2d plot in 1 3D plot with common origin point

4 次查看(过去 30 天)
hello,
say i already have a 2d plot of pressure vs distance from origin in x,y and 45\deg direction.
now i want to get the visualization of these pressure in 3d by joining these 3 plot into one point (the origin point)
i want to create exactly like the attached picture, can you suggest me some command that can help me achive this goal.
thank you

采纳的回答

John D'Errico
John D'Errico 2022-2-27
编辑:John D'Errico 2022-2-27
Not nearly as hard as it may seem. Or, maybe this seems like it should be easy, and so my solution is actually harder than you would think? DRAT. Now I'm confusing myself. Oh well, here is my (simple) solution. I'll do it using my own data, since I have no real data from you to use.
First, I need a tool that can rotate the axes around the z axis, by theta degrees. I've done it here in terms of degrees, since people seem to like that. The function is given below, as xyrot.
For example, this little function (xyrot) maps a point [x,y z], into a new rotated point (xnew,ynew,z], thus a rotation of theta degrees in a counter-clockwise direction around the z axis. z will remain unchanged. For example, mapping the point [1 0 z], by 45 degrees gives me this:
[xnew,ynew] = xyrot(1,0,45)
xnew = 0.7071
ynew = 0.7071
Good. That works. A good idea is ALWAYS to test your code as you write it. Does it do what you expect?
Next, I need to make up some data. First, I need a surface. The surface itself will be a simple planar one.
nx = 100;
nz = 100;
[x,z] = meshgrid(linspace(0,1,nx),linspace(0,1,nz));
y = zeros(nx,nz);
In each of these rotated planar surfaces, I will have some relationship, where a 4th paramter is encoded in terms of color.
C0 = sin(3*(x+z));
C45 = sin(4*(x+z));
C90 = sin(5*(x+z));
surf(x,y,z,C0)
hold on
[x45,y45] = xyrot(x,y,45);
surf(x45,y45,z,C45)
[x90,y90] = xyrot(x,y,90);
surf(x90,y90,z,C90)
shading interp
hold off
box on
grid on
You should get the idea though. I can plot as many image planes as I desire. Or, if my planes were respectively various Monet pictures of water lillies, that would have been as easy to show, one in each plane. With a little effort, I can also make it simpler and more automated, but you should get the idea.
Of course, I just used the default color map for these image planes. If the array C as passed into surf is an actual 100x100x3 color array in each case, then you will get the flame-like results that you show in the picture posted in your question.
function [xnew,ynew] = xyrot(x,y,theta)
% rotate x and y around the z axis, by theta degrees
xnew = x*cosd(theta) - y*sind(theta);
ynew = x*sind(theta) + y*cosd(theta);
end
  1 个评论
Mahardika Firjatullah
THANK YOU SO MUCH FOR YOUR HELP!!
one note that what i actually do is to plot pressure in just one value of z (no variation in the z direction) so what i do is i assign the pressure value to the color indicator and then activate the colorbar indicator
this is my result

请先登录,再进行评论。

更多回答(1 个)

Matt J
Matt J 2022-2-27
slice()?

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by