How to plot a number of parametric/vector equations from data in Excel?

1 visualización (últimos 30 días)
I would like to input a number of vector equations of the form V = A + tB. I have an excel spreadsheet containing the required data, in which the position and direction vectors A and B respectively are defined with columns for x, y and z values. I have tried to use something of the like:
t = linspace(0, 2*pi);
x = data(:,1) + t.*data(:,2)
y = data(:,3) + t.*data(:,4)
z = data(:,5) + t.*data(:,6)
plot3(x,y,z)
But it does not yield what it should. Anyone can help me figure this out? What am I doing wrong and how can I fix it?
EDIT: I have specific vectors for specific values of t. In my table, I could choose to include the column for values of t. Does this change anything or do I just need to alter my linspace values?
EDIT2: Here is the input you gave me that I adjusted. The figure is blank, just axis. bpbondsA = dataA and bpbondsB = dataB
N = 22 ;
bpbondsA = rand(N,3) ;
bpbondsB = rand(N,3) ;
xA = bpbondsA(:,1) ; xB = bpbondsB(:,1) ;
yA = bpbondsA(:,2) ; yB = bpbondsB(:,2) ;
zA = bpbondsA(:,3) ; zB = bpbondsB(:,3) ;
t = linspace(0,12.56637,22) ;
Vx = cell(N,1) ; Vy = cell(N,1) ; Vz = cell(N,1) ;
figure
hold on
for i =1:N
Vx{i} = xA(i)+t*xB(i) ;
Vy{i} = yA(i)+t*yB(i) ;
Vz{i} = zA(i)+t*xB(i) ;
plot3(Vx{i},Vy{i},Vz{i})
EDIT3: Attached the excel spreadsheet with the data on.

Respuesta aceptada

KSSV
KSSV el 3 de Jul. de 2017
Editada: KSSV el 3 de Jul. de 2017
Let dataA and dataB be (x,y,z) points for A and B read from excel file.
N = 10 ;
dataA = rand(N,3) ;
dataB = rand(N,3) ;
xA = dataA(:,1) ; xB = dataB(:,1) ;
yA = dataA(:,2) ; yB = dataB(:,2) ;
zA = dataA(:,3) ; zB = dataB(:,3) ;
t = linspace(0,2*pi) ;
Vx = cell(N,1) ; Vy = cell(N,1) ; Vz = cell(N,1) ;
figure
hold on
for i =1:N
Vx{i} = xA(i)+t*xB(i) ;
Vy{i} = yA(i)+t*yB(i) ;
Vz{i} = zA(i)+t*xB(i) ;
plot3(Vx{i},Vy{i},Vz{i})
end
  17 comentarios
KSSV
KSSV el 3 de Jul. de 2017
Put the data in text file instead of excel file.
Marco Froelich
Marco Froelich el 3 de Jul. de 2017
Yes but it will yield ultimitaly the same plot

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by