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!