2-D graph help
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ogen
el 10 de Feb. de 2016
Comentada: Star Strider
el 6 de Mzo. de 2016
Hi everyone. I would like to produce a graph like the one shown in the picture on MatLAB. Any help with writing the script will be greatly appreciated. The radius of each band increases from the central point 0,0.
0 comentarios
Respuesta aceptada
Star Strider
el 10 de Feb. de 2016
One possibility:
w = linspace(0, 2*pi);
c = [cos(w); sin(w)];
r = [1 2 3];
figure(1)
plot(r(1)*c(1,:), r(1)*c(2,:))
hold on
plot(r(2)*c(1,:), r(2)*c(2,:))
plot(r(3)*c(1,:), r(3)*c(2,:))
hold off
axis equal
5 comentarios
Star Strider
el 10 de Feb. de 2016
My pleasure.
The mushroom cloud problem would seem to be a computational fluid dynamics problem far beyond the scope of my knowledge. However, if you want to plot a cone plotting the radius at different heights, and perhaps the shape of the cloud itself, I would investigate the cylinder function. It, possibly in combination with the sphere function, could give you the result you want. This code uses both:
[Xc,Yc,Zc] = cylinder(0.5, 20);
[Xs,Ys,Zs] = sphere(20);
Xsm = Xs * 2;
Ysm = Ys * 2;
Zsm = Zs + 2;
figure(1)
surf(Xc,Yc,Zc)
hold on
surf(Xsm,Ysm,Zsm)
hold off
grid on
axis equal
view([-35 20])
to produce:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/182160/image.png)
Más respuestas (2)
Ogen
el 10 de Feb. de 2016
5 comentarios
Star Strider
el 6 de Mzo. de 2016
My pleasure.
The drawnow function is useful inside a loop, so that you calculate and draw each frame and animate it in real time. This works best if the calculations creating the image are reasonably fast, and the resolution relatively low.
The getframe function and its friends allow you to create a movie out of your MATLAB images. This is best if the calculations for each frame take a while, are relatively high resolution, and so are not suited to real time display. If you have detailed images that take some time to render and you don’t need to change the parameters of the simulation in real time, this is likely the better option.
It all depends on what you want to depict. I last did this sort of thing many years ago when MATLAB, and PCs in general, were slower, so getframe was the best option for me. I've used drawnow recently with good results, but with simpler code.
Ogen
el 10 de Feb. de 2016
4 comentarios
Star Strider
el 11 de Feb. de 2016
UPDATE — I did some Web searching, and discovered Dr. Jos Stam’s website at the University of Toronto http://www.dgp.toronto.edu/people/stam/reality/Research/pub.html. See specifically ‘Real-Time Fluid Dynamics for Games’. There’s also a CDROM, but I doubt the code’s written in MATLAB, so you’d have to adapt it. I found it through Mushroom Cloud Physics on ‘gamedev.net’. (I’m a gamer, so I can’t explain this not occurring to me earlier, other than that I do primarily medieval-themed games where mushroom clouds are rare and dragons are plentiful.)
If I find anything else, I’ll post it here.
Ver también
Categorías
Más información sobre Geometry and Mesh en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!