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

조회 수: 1 (최근 30일)
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.

채택된 답변

KSSV
KSSV 2017년 7월 3일
편집: KSSV 2017년 7월 3일
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
KSSV
KSSV 2017년 7월 3일
Put the data in text file instead of excel file.
Marco Froelich
Marco Froelich 2017년 7월 3일
Yes but it will yield ultimitaly the same plot

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by