Struggling to connect end points of lines within a plot
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Joshua Tsui
le 11 Mar 2021
Réponse apportée : Joshua Tsui
le 12 Mar 2021
Hello,
I am having issues creating the following plot:
So far, I have been able to create the F shape but I have run into a few issues:
1) A horizontal line is plotted at floor zero. I am not sure what I have done to make this happen.
2) I am struggling to create the dashed lines which connect the horizontal lines as I am unsure how to extract these values and connect them to (0,0).
Here is my code so far:
numFlr=2
Phi_EigVec=[1 3;2 -3;]
y1=zeros(numFlr,1);
y2=zeros(numFlr,1);
x1=zeros(numFlr,1);
x2=Phi_EigVec(:,1);
hold on
xline(0)
for i=1:numFlr,
y1(i)=i
y2(i)=i
A = [x1(:) x2(:)]; B = [y1(:) y2(:)];
plot(A.',B.','LineWidth', 0.75)
end
axis([-5 5 -1 5])
0 commentaires
Réponse acceptée
KSSV
le 11 Mar 2021
L = [0 -1; 0 0 ; 0 1 ; 0 2 ] ;
R = [0 -1; 2 0 ;1 1 ; 2 2] ;
plot(L(:,1),L(:,2),'r')
hold on
plot(R(:,1),R(:,2),'r')
plot([L(:,1) R(:,1)]',[L(:,2) R(:,2)]','g')
2 commentaires
KSSV
le 11 Mar 2021
L = [0 -1; 0 0 ; 0 1 ; 0 2 ] ;
R = [0 -1; 2 0 ;1 1 ; 2 2] ;
plot(L(:,1),L(:,2),'r')
hold on
plot(R(:,1),R(:,2),'r')
plot([L(3:end,1) R(3:end,1)]',[L(3:end,2) R(3:end,2)]','g')
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Polar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!