Warning: Function figure has the same name as a MATLAB builtin.

6 vues (au cours des 30 derniers jours)
Cumpaniciu Alexandru
Cumpaniciu Alexandru le 23 Mai 2020
Commenté : Walter Roberson le 24 Mai 2020
HI,I am new to Matlab and I am trying this code,but it is not working...can you help me please.
Warning: Function figure has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.\
how can i do this? what do i need to change?
THIS CODE WAS TESTED IN MATLAB 2020a...
lambda = 1866;
delta1=0.309;
delta2=0.251;
rho=0.457 ;
alpha = 0.177;
mu = 194;
omega = 0.256 ;
eta1 = 0.341 ;
eta2= 3.78 ;
beta = 0.569;
c = 15.5 ;
mu0 = 0.087;
mu1 = 0.172;
%bmax = 1.8 ; % backward b if u r c at i o n
bmax =10.8;% forward b if u r c at i o n
rend=100000;
rlst=linspace(0,2,rend) ;
mylist1=zeros( 1, length (rlst));
mylist2=zeros( 1 , length ( rlst ));
mylist3=zeros(1,length (rlst));
Q1= mu + alpha + delta1 ;
Q2= delta2 + mu + omega ;
for i =1:1:rend
r=rlst(i) ;
% Ao, A1 , A2 , A3 are the c o e f f i c i e n t s of the polynomial obtained t the
% endemic equilibrium point E*
Ao = beta * c * (mu0 + Q1 ) * (mu0* ( delta2 * eta2 + eta1 * rho ) + Q2* ( delta1*eta2+rho ) ) ;
A1 = beta * c * ( delta2 * eta2 + eta1 * rho ) * (mu0* ( 2 *bmax*mu1 + bmax*Q1+lambda) + bmax*mu1*Q1) + Q2* ( beta * c * delta1 * eta2 * ( bmax* (mu0 + mu1)-lambda) + beta * c * rho * ( bmax*mu1- lambda ) + mu0* rho * ( beta *bmax* c + mu )+Q1* ( 2 * beta *bmax* c * delta1 * eta2 + rho * ( 2 * beta *bmax* c + mu) ) ) ;
A2= bmax* (Q2* ( beta * c * delta1 * eta2 * ( bmax*mu1-2*lambda )+rho * (mu1* ( beta *bmax* c + mu )-2* beta * c *lambda + mu*mu0) +Q1* ( beta *bmax* c * delta1 * eta2 + beta *bmax* c * rho + 2*mu * rho ) ) +beta * c * ( delta2 * eta2 + eta1 * rho ) * (mu1* ( bmax* (mu1 + Q1) + lambda ) +lambda*mu0));
A3= bmax^2*rho *Q2*mu* (Q1 + mu1)*(1-r ) ;
mypoly=[Ao, A1 , A2 ,A3 ] ;
sol=roots( mypoly ) ; % we plot the root s ( sol ) of the polynomial mypoly
mylist1(i)=sol(1);
mylist2( i )= sol( 2 ) ;
mylist3 ( i )= sol( 3 ) ;
% we r epl a c e negative root s by zero and only st o r e the r e a l p o s it i v e
% root s into myli st
if imag( mylist1 (i))~=0
mylist1(i)=0;
else
mylist1 ( i )=max( 0 , mylist1 ( i) ) ;
end
if imag( mylist2 ( i ))~=0
mylist2 ( i ) = 0 ;
else
mylist2 ( i )=max( 0 , mylist2 ( i ) ) ;
end
if imag( mylist3 ( i ))~=0
mylist3( i ) = 0 ;
else
mylist3(i)= max( 0 , mylist3 ( i ) ) ;
end
end
% we determine the number i from the r l i s t fo r each fun ction myli st
% where the root of the polynomial i s r e a l and p o s it i v e .
lstpos=find( mylist1 ~=0);
index1=min( lstpos ) ;
index2=max( lstpos ) ;
mlstpos=find ( mylist2 ~=0);
index3=min( mlstpos ) ;
index4=max( mlstpos ) ;
vlstpos=find ( mylist3 ~=0);
index5=min(vlstpos) ;
index6=max(vlstpos) ;
% we formulate the di s ea s e f r e e equilibrium l i n e s on the x−a xi s
s=linspace( 0 ,1,rend) ;
z=linspace (1,1.5, rend);
y1= + 0*s ;
y2= + 0*z ;
%a xi s ( [ 0 . 3 , 1 . 5 , 0 , 5 ] ) % backward b if u r c at i o n
axis ( [ 0.7 , 1.5 , 0, 4 ] ) % forward b if u r c at i o n
hold on
%we plot the p o s it i v e root s of the polynomial
%plot ( r l s t ( index1 : index2 ) , myli st1 ( index1 : index2 ) , ’ b−’ ,
%r l s t ( index3 : index4 ) , myli st2 ( index3 : index4 ) , ’ b−’ , r l s t ( index5 : index6 ) ,
%myli st3 ( index5 : index6 ) , ’ r −−’,’ linewidth ’ ,2)% bacward b if u r c at i o n
plot(rlst( index1 : index2 ), mylist1 ( index1 : index2 ) ,' b-',rlst( index3 : index4 ),mylist2( index3 : index4 ) ,' b-',rlst( index5 : index6 ) , mylist3 ( index5 : index6 ) , 'b−' , 'linewidth ' ,2)% forwar
plot ( s , y1 , 'b− ' , 'linewidth ' , 2 )
plot ( z , y2 , ' r −−',' linewidth' , 2 )
%x l im it ( [ 0 . 2 , 1 . 8 ] )
xlabel ( ' Reproduction number Rh ' )
ylabel ( 'Infected population s i z e I ( t ) ' )
hold off
  2 commentaires
Stijn Haenen
Stijn Haenen le 23 Mai 2020
You try to define a variable or function which has the same name as a standard function of matlab, you can use capital letters or _ when you define your variables or function to avoid this problem.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Mai 2020
You named your file figure.m which will cause problems. You should rename the file for your code.
  9 commentaires
Cumpaniciu Alexandru
Cumpaniciu Alexandru le 24 Mai 2020
I need define an function or somthing else?
If so, how could I do that?
what are the outputs and inputs for my code?
Walter Roberson
Walter Roberson le 24 Mai 2020
What is the exact name of the the file you are using for this code?
What shows up if you you try
which -all figure

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Signal Processing Toolbox 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!

Translated by