How to plot data along a path in the x-y plane?
4 次查看(过去 30 天)
显示 更早的评论
I am trying to create a 2D plot of a set of data points along a path in the x-y plane given by the coordinates (0,0) to (pi,0) to (pi,pi) to (0,0). This would mean plotting along the line y = 0 where x varies from 0 to pi first, then plotting along the line x = pi where y varies from 0 to pi second, and finally plotting along the line y = x where both x and y go from pi to 0. Is there a way to do this?
What I am essentially looking for is to do something like this:
for r=1:Nsites
plot(k,Vfull(r,:),'.b')
end
where
Vfull(r,:)
specifies the row r containing the data points. I would like
k
to be the array of points along the specified path.
0 个评论
回答(1 个)
KSSV
2017-11-14
N = 100 ;
th = linspace(0,pi,N)' ;
L1 = [th zeros(size(th))] ;
L2 = [pi*ones(size(th)) th] ;
L3 = [flipud(th) flipud(th)] ;
L = [L1 ; L2 ; L3] ;
figure
plot(L(:,1),L(:,2))
figure
hold on
plot(L1(:,1),L1(:,2))
plot(L2(:,1),L2(:,2))
plot(L3(:,1),L3(:,2))
legend('L1','L2','L3')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!