Extracting data from an array

9 visualizzazioni (ultimi 30 giorni)
Matt Tomei
Matt Tomei il 22 Ott 2020
Risposto: Sindar il 23 Ott 2020
I am interested in plotting a curve to show the path of a point (B) on a rotating gear. This gear is attahced to an arm that makes one full revolution.
I have a for loop to evaluate theta from 0 to 2*pi (for theta=0:pi/180:2*pi). While the for loop runs, the position of point B is stored in a previously initialized, empty array (B=[]). The resulting array is 4x1 and I would like to extract only the first 3 rows to obtain the x,y,z components of the point's position. I intend to then use these x,y,z components to plot the path of the point using plot3(x,y,z).
Can anyone help me to extract the first 3 rows from the 4x1 array? Also, from this new 3x1 array, what would the arguments be in order to use plot3(x,y,z) properly?

Risposte (1)

Sindar
Sindar il 23 Ott 2020
To extract the first three rows:
B3 = B(1:3,:);
x = B3(1,:);
y = B3(2,:);
z = B3(3,:);
But, if B is really 4x1, then you only have a single point

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by