Result running in command window did'nt sincron with result in curve

1 回表示 (過去 30 日間)
Nur Wahidiyatil
Nur Wahidiyatil 2023 年 3 月 13 日
コメント済み: Sachin 2023 年 3 月 14 日
I have coding phase portrait but result in command window and in the curve didd't same. I want see value of first variable and second variable. This is the coding
clc; close all; clear all;
figure1 = figure ;
axes1 = axes ( 'Parent' , figure1 , 'fontsize' , 13 ) ;
grid on;
box(axes1,'on') ;
hold(axes1,'all') ;
%plotArrows = @(m) quiver(m(:,1),m(:,2), gradient(m(:,1)), gradient (m(:,2)));
global k e1 e2 a1 a2 b1 b2 m r q w1 w2 s;
k=1400;
e1=0.0000006;
e2=0.0000005;
a1=0.0000002;
a2=0.0000007;
b1=0.000005;
b2=0.0008;
m=0.001;
r=0.03;
q=0.05;
w1=0.14;
w2=0.11;
s=0.002;
[t1,y1]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[20 20 10 20 5]);
[t2,y2]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[20 18 10 50 20]);
[t3,y3]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[50 10 90 40 20]);
[t4,y4]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[10 50 90 40 10])
figure(1);
plot(y1(:,1), y1(:,2),'blue',y2(:,1), y2(:,2),'red',y3(:,1),y3(:,2),'green',y4(:,1),y4(:,2),'black','linewidth',2);
%plotArrows(y1),
%plotArrows(y2),
%plotArrows(y3),
%plotArrows(y4),
legend('Nilai Awal 1','Nilai Awal 2','Nilai Awal 3','Nilai Awal 4');
xlabel('Jumlah Populasi Rentan yang Memiliki Berat Badan Normal');
ylabel('Jumlah Populasi Rentan yang Obesitas');
%R0=sqrt((gamma*k1*beta*k2*alfa)/(d*(alfa+m)*(delta+m)))
The first variable is horizontal and second variable is vertical. In the curve, value of first variable is 12250, but value of first variable in comand window is 22200.

回答 (1 件)

Sachin
Sachin 2023 年 3 月 13 日
Based on my understanding, you are facing an issue with the output. Referring to the following information may be helpful to you, assuming that you are using MATLAB R2022b.
  1. You are getting different values in the curve and command window. This is because the MATLAB command window has a limit to display data in the command window. Therefore, it is only showing the last rows of the data as the data is too long.
  2. If you observe 2nd and 3rd column have value ‘0’ it is because data is extremely small. MATLAB is rounding extremely small values to 0.
  3. I recommend you place a breakpoint at plot line so that you can see values are correct.
plot(y1(:,1), y1(:,2),'blue',y2(:,1), y2(:,2),'red',y3(:,1),y3(:,2),'green',y4(:,1),y4(:,2),'black','linewidth',2);
  2 件のコメント
Nur Wahidiyatil
Nur Wahidiyatil 2023 年 3 月 14 日
How place breakpoint at plot line ?
Sachin
Sachin 2023 年 3 月 14 日
In the left side of your code you can place breckpoint. After placing the breckpoint when you run the progrem you will see that execution stops at breckpoint line and in the workspace you will see variable t1,y1,t2,y3... etc.

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

カテゴリ

Help Center および File ExchangeGraphics Object Identification についてさらに検索

タグ

製品


リリース

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by