필터 지우기
필터 지우기

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?

조회 수: 5 (최근 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
William Warren
William Warren 2015년 10월 26일
Thank you, that definitely makes the first step easier, but what about linking the vectors tip to tail?
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에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by