I have trouble when plot with quiver
이전 댓글 표시
can you help me to fix this script . I want to plot a potrait phase with arrow , but this script just run on matlab 2021a. but,
my matlab ver. 2007.
clc; clear;
figure1=figure;
axes1=axes('Parent',figure1,'fontsize',13);
grid on;
box(axes1,'on');
hold(axes1,'all');
to = 0;
tf = 30;
tspan = to:0.1:tf;
plotArrows = @(m) quiver(m(:,1), m(:,5), gradient(m(:,1)), gradient(m(:,5)));
figure
iv1 = [ 12.3 0.1 0 0.1 0.1 ] ;
[t y] = ode45(@(t, y) lnear(t, y), tspan, iv1);
plotArrows(y), hold on
iv2 = [ 12.3 0 0 0 0 ] ;
[t x] = ode45(@(t, x) lnear(t, x), tspan, iv2);
plotArrows(x),
iv3 = [ 12.65 0 0 0.1 0.1 ] ;
[t z] = ode45(@(t, z) lnear(t, z), tspan, iv3);
plotArrows(z),
iv4 = [ 12.65 0.1 0.1 0 0 ] ;
[t n] = ode45(@(t, n) lnear(t, n), tspan, iv4);
plotArrows(n),
iv5 = [ 12.485594 0 0 0 0.12 ] ;
[t w] = ode45(@(t, w) lnear(t, w), tspan, iv5);
plotArrows(w),
iv6 = [ 12.3 0.1 0 0.1 0 ] ;
[t v] = ode45(@(t, v) lnear(t, v), tspan, iv6);
plotArrows(v),
iv7 = [ 12.4 0.05 0 0.05 0 ] ;
[t s] = ode45(@(t, s) lnear(t, s), tspan, iv7);
plotArrows(s),
iv8 = [ 12.65 0.05 0 0.05 0.05 ] ;
[t p] = ode45(@(t, p) lnear(t, p), tspan, iv8);
plotArrows(p),
iv9 = [ 12.6 0.05 0 0.05 0 ] ;
[t c] = ode45(@(t, c) lnear(t, c), tspan, iv9);
plotArrows(c), grid on
xlabel('y_1'), ylabel('y_5')
function dydt = lnear(t,y)
dydt = zeros(5, 1);
e1 = 13;
g = 0.0125;
h = 0.284253;
f = 0.05;
q1 = 0;
k1 = 10;
d1 = 0.0412;
e2 = 0.0188;
j = 0.0082;
q2 = 0;
k2 = 10;
d2 = 0.0288;
b = 2;
d4 = 0.1152;
e3 = 0.166667;
a = 1.7;
q3 = 0;
k3 = 10;
d3 = 0.1152;
r = 0.5;
m = 1.02;
q4 = 0;
k4 = 10;
dydt(1) = e1 + (g*y(3)*y(1)/(h + y(3))) + (f*y(3)*y(1)) - (y(1)*(1 + ((q1/k1)*y(1)))) - (d1*y(1));
dydt(2) = e2*y(2) + (f*y(1)*y(3)) - (j*y(2)) - (y(2)*(1 + ((q2/k2)*y(2)))) - (d2*y(2));
dydt(3) = (b*e2*y(2)) - (d4*y(3));
dydt(4) = e3*y(4) + (j*y(2)) - (a*y(4)) - (y(4)*(1 + ((q3/k3)*y(4)))) - (d3*y(4));
dydt(5) = (r*y(5)*(1 - (m*y(5)))) + (a*y(4)) - y(5)*(1 + ((q4/k4)*y(5)));
end
답변 (1개)
Nur Wahidiyatil
2023년 2월 17일
0 개 추천
댓글 수: 4
Nur Wahidiyatil
2023년 2월 17일
Star Strider
2023년 2월 17일
Copy only the function code to a new window (tab) in the MATLAB Editor, then save the function in a file named lnear.m and the code should then work correctly. Also, delete it from the script file that contains the rest of the code and then save the script file.
If possible, upgrade to the latest MATLAB release.
Nur Wahidiyatil
2023년 2월 19일
Nur Wahidiyatil
2023년 2월 19일
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

