Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Saavanth Velury
Saavanth Velury am 13 Nov. 2017
Beantwortet: KSSV am 14 Nov. 2017
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.

Antworten (1)

KSSV
KSSV am 14 Nov. 2017
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')

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by