# How to plot data along a path in the x-y plane?

19 ビュー (過去 30 日間)
Saavanth Velury 2017 年 11 月 13 日

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.

サインインしてコメントする。

### 回答 (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')

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!