how can i plot the arrows like in the targeted phase-plane portraits at the initial points?
조회 수: 2 (최근 30일)
이전 댓글 표시
How do I draw the arrow like in the first picture(the targeted phase-plane portraits )?
the targeted phase-plane portraits
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145998/image.png)
my phase-plane portraits
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145999/image.png)
Attached is the code for my phase portraits.
댓글 수: 0
답변 (1개)
Orion
2014년 11월 6일
Hi,
Modifying your script phase_plane_example5, you could do something something like
clear
clc
X = [];
Y = [];
U = [];
V = [];
color = 'mrb';
for i=0:10:60
for j=-5:5:5
b = i;
a = j;
k = j/5+2;
[t,x] = ode45('mpac',0:0.01:10,[a/57.3;b/57.3]);
plot(a,b,'*k');
hold on;
plot(x(:,1)*57.3,x(:,2)*57.3,color(k));
% stock the positions.
X = [X,x(:,1)*57.3];
Y = [Y,x(:,2)*57.3];
% calculate and stock the derivatives.
U = [U,diff(x(:,1)*57.3)./diff(t)];
V = [V,diff(x(:,2)*57.3)./diff(t)];
end
end
title('Phase plane plot of roll dynamics');
xlabel('Roll angle(deg)');
ylabel('Roll rate(deg/s)');
grid on;
% add an initial line of values to the derivatives terms to have the same
% length vectors and match the position ones.
U=[zeros(1,21);U];
V=[zeros(1,21);V];
% draw the arrows.
quiver(X,Y,U,V);
댓글 수: 3
Orion
2014년 11월 7일
편집: Orion
2014년 11월 7일
1) I inversed my concatenation : you must use
U=[U;zeros(1,21)];
V=[V;zeros(1,21)];
zeros is just used here to make the speed vectors of the same size of the position vectors.
2) if you want to play with the propoerties of the quiver plot (size for example)
q = quiver(X,Y,U,V);
set(q,'AutoScaleFactor',6);
as a result
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179441/image.jpeg)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!