How can I plot a series of vectors, tip-to-tail, that begins at the origin and closes as if drawing them out by hand?

4 次查看(过去 30 天)
clear
close all
clc
vectors = xlsread('Book1.xlsx'); %Enter any .xlsx document here
[M,N] = size(vectors);
for i=1:M
x = (vectors(i,1)*cosd(vectors(i,2)))
y = (vectors(i,1)*sind(vectors(i,2)))
plot(x,y,'o')
end
  4 个评论
Stefan Raab
Stefan Raab 2015-10-26
I don't know if this is the best solution, but it should work that way for your example (generally you have to be careful if x,y are column or row vectors):
x = (vectors(:,1).*cosd(vectors(:,2)));
y = (vectors(:,1).*sind(vectors(:,2)));
plot([x; x(1)],[y; y(1)]);
Kind regards, Stefan

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-10-26

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by