Need help creating 3d plot of 3 equally sized vectors (trajectory problem)

2 visualizzazioni (ultimi 30 giorni)
Hello all before I get started my code is hyperlinked here: Matlab Code
Now I am currently working on a problem in which I'm using the RK2 method of numerical integration to solve for the trajectory of a ball (the vector r). I've created the dummy variables for each coordinate (x,y and z in dummyx, dummy and dummyz) to allow me to collect all the values and thus plot a trajectory at each time step. I'm attempting to use those variable to make a 3d plot of the trajectory.
Initially I tried plot3(dummyx, dummyy, dummyz) but it gave me a 2d plot
then I tried the triangulation using TRI = delaunay(dummyx, dummyy, dummyz) and trisurf(TRI, dummyx, ...) but kept getting errors regarding the patch function (but i didn't use it?) and telling me my values need be Nx1 or Nx3 vectors. So I transposed my vectors and it still didn't work.
Now I've tried the quiver3 plot (as it will give the values of velocity at each point too) and made the requisite dummy variables for my velocity vector and when I run the code I get another 2D plot! Not sure why I can't seem to get a 3D plot with any of these methods.
I don't really need the quiver plot to work, just something simple like plot3 but I can't understand why I'm not getting 3D plots when I'm feeding it 3 1x10000 row vectors? Any help is GREATLY appreciated!
  1 Commento
Looky
Looky il 30 Ott 2017
Your code produces a nice 3d-Plot for me. Are you sure that your plot is 2d or didn't you try to use the rotate button in the figure window to rotate it. By default it might show you the x-y plane, what might look like a 2d plot.
Use the rotate 3d button (top of the figure) to change view or use the view function.
On a side note, pls consider preallocation for your dummyxyz array. This can speed up your code a lot. (just add dummyx=zeros([1,n]); before the for loop for all dummy* vectors)

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by