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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!