i am not getting plot

function run_LE_FO_p1(ne,ext_fcn,t_start,h_norm,t_end,x_start,h,q,p_min,p_max,n);
hold on;
ne=3;
ext_fcn=@LE_RF_p1;
t_start=0;h_norm=0.02;t_end=10;
x_start=[0.1 0.1 0.1];h=0.02;q=0.998;
p_max=1.3;
p_min=1.1;
n=800;
p_step=(p_max-p_min)/n
p1=p_min;
while p1<=p_max
lp=FO_Lyapunov_p1(ne,ext_fcn,0,0.02,10,[0.1 0.1 0.1],0.002,0.998,p1)
p1=p1+p_step;
plot(p1,lp)
end
function LE=FO_Lyapunov_p1(ne,ext_fcn,t_start,h_norm,t_end,x_start,h,q,p1);
% Memory allocation
x=zeros(ne*(ne+1),1);
x0=x;
c=zeros(ne,1);
gsc=c; zn=c;
n_it = round((t_end-t_start)/h_norm);
% Initial values
x(1:ne)=x_start;
i=1;
while i<=ne
x((ne+1)*i)=1.0;
i=i+1;
end
t=t_start;
% Main loop
it=1;
while it<=n_it
% Solutuion of extended ODE system of FO using FDE12 routine
[T,Y] = FDE12(q,ext_fcn,t,t+h_norm,x,h,p1);
t=t+h_norm;
Y=transpose(Y);
x=Y(size(Y,1),:); %solution at t+h_norm
i=1;
while i<=ne
j=1;
while j<=ne;
x0(ne*i+j)=x(ne*j+i);
j=j+1;
end;
i=i+1;
end;
% construct new orthonormal basis by gram-schmidt
zn(1)=0.0;
j=1;
while j<=ne
zn(1)=zn(1)+x0(ne*j+1)^2;
j=j+1;
end;
zn(1)=sqrt(zn(1));
j=1;
while j<=ne
x0(ne*j+1)=x0(ne*j+1)/zn(1);
j=j+1;
end
j=2;
while j<=ne
k=1;
while k<=j-1
gsc(k)=0.0;
l=1;
while l<=ne;
gsc(k)=gsc(k)+x0(ne*l+j)*x0(ne*l+k);
l=l+1;
end
k=k+1;
end
k=1;
while k<=ne
l=1;
while l<=j-1
x0(ne*k+j)=x0(ne*k+j)-gsc(l)*x0(ne*k+l);
l=l+1;
end
k=k+1;
end;
zn(j)=0.0;
k=1;
while k<=ne
zn(j)=zn(j)+x0(ne*k+j)^2;
k=k+1;
end
zn(j)=sqrt(zn(j));
k=1;
while k<=ne
x0(ne*k+j)=x0(ne*k+j)/zn(j);
k=k+1;
end
j=j+1;
end
% update running vector magnitudes
k=1;
while k<=ne;
c(k)=c(k)+log(zn(k));
k=k+1;
end;
% normalize exponent
k=1;
while k<=ne
LE(k)=c(k)/(t-t_start);
k=k+1;
end
i=1;
while i<=ne
j=1;
while j<=ne;
x(ne*j+i)=x0(ne*i+j);
j=j+1;
end
i=i+1;
end;
x=transpose(x);
it=it+1;
end
function f=LE_RF_p1(t,x,p1)
%p is the parameter
f=zeros(9,1);
X= [x(4) x(7) x(10);
x(5) x(8) x(11);
x(6) x(9) x(12)];
%RF equations
f(1)=x(2).*(x(3)-1+x(1).*x(1))+0.1*x(1);
f(2)=x(1).*(3*x(3)+1-x(1).*x(1))+0.1*x(2);
f(3)=-2.*x(3).*(p1+x(1).*x(2));
%Jacobian matrix
J=[2*x(1).*x(2)+0.1, x(1).*x(1)+x(3)-1, x(2);
-3*x(1).*x(1)+3*x(3)+1,0.1,3*x(1);
-2*x(2).*x(3),-2*x(1).*x(3),-2*(x(1).*x(2)+p1)];
f(4:12)=J*X; % To be modified if ne>3
I am not getting plot

Answers (1)

Voss
Voss on 24 May 2022
lp seems to always be a 1-by-3 vector and p1 is a scalar. Therefore
plot(p1,lp)
creates three lines, each with one point. You cannot see a line with one point unless it has a data marker. So add a data marker and you'll see something (and add a drawnow and you'll see it update live):
plot(p1,lp,'.');
drawnow();

9 Comments

it's not working
for p1=1.1:0.05:1.3;
while p1<=p_max
lp=FO_Lyapunov_p1(ne,ext_fcn,0,0.02,1,[0.1 0.1 0.1],0.002,1,p1)
p1=p1+p_step;
plot(p1,lp,'.')
drawnow();
end
end
i tried this way also but i didn't get any plot
Maybe create a new figure at the beginning of run_LE_FO_p1:
function run_LE_FO_p1(ne,ext_fcn,t_start,h_norm,t_end,x_start,h,q,p_min,p_max,n);
figure();
hold on;
so that the plots don't go into an existing figure that you're not watching.
An m-file containing the code from your question with only those two changes (data marker/drawnow and figure() call) is attached here, and it runs on my machine.
thanks
Voss
Voss on 24 May 2022
welcomes
nune pratyusha
nune pratyusha on 24 May 2022
Edited: nune pratyusha on 24 May 2022
sorry to ask again i am implementing above code to 4 dimensional i am getting so many errors please help me
function run_LE_FO_a(ne,ext_fcn,t_start,h_norm,t_end,x_start,h,q,a_min,a_max,n);
figure();
hold on;
ne=4;
ext_fcn=@LE_RF_a;
t_start=0;h_norm=0.02;t_end=1;
x_start=[0 0 1 1];h=0.2;q=1;
a_max=-11;
a_min=-12.2;
n=800;
p_step=(a_max-a_min)/n
a=a_min;
% for p1=1.1:0.1:1.3;
while a<=a_max
lp=FO_Lyapunov_a(ne,ext_fcn,0,0.2,1,[0 0 1 1],0.2,1,a)
a=a+p_step;
plot(a,lp,'.')
drawnow();
% end
end
function LE=FO_Lyapunov_a(ne,ext_fcn,t_start,h_norm,t_end,x_start,h,q,a);
% Memory allocation
x=zeros(ne*(ne+1),1);
x0=x;
% y0=x_start
c=zeros(ne,1);
gsc=c; zn=c;
n_it = round((t_end-t_start)/h_norm);
% Initial values
x(1:ne)=x_start;
i=1;
while i<=ne
x((ne+1)*i)=1.0;
i=i+1;
end
t=t_start;
% Main loop
it=1;
while it<=n_it
% Solutuion of extended ODE system of FO using FDE12 routine
[T,Y] = FDE12(q,ext_fcn,t,t+h_norm,[0 0 1 1],h,a);
t=t+h_norm;
Y=transpose(Y);
x=Y(size(Y,1),:); %solution at t+h_norm
i=1;
while i<=ne
j=1;
while j<=ne;
x0(ne*i+j)=x(ne*j+i);
j=j+1;
end;
i=i+1;
end;
% construct new orthonormal basis by gram-schmidt
zn(1)=0.0;
j=1;
while j<=ne
zn(1)=zn(1)+x0(ne*j+1)^2;
j=j+1;
end;
zn(1)=sqrt(zn(1));
j=1;
while j<=ne
x0(ne*j+1)=x0(ne*j+1)/zn(1);
j=j+1;
end
j=2;
while j<=ne
k=1;
while k<=j-1
gsc(k)=0.0;
l=1;
while l<=ne;
gsc(k)=gsc(k)+x0(ne*l+j)*x0(ne*l+k);
l=l+1;
end
k=k+1;
end
k=1;
while k<=ne
l=1;
while l<=j-1
x0(ne*k+j)=x0(ne*k+j)-gsc(l)*x0(ne*k+l);
l=l+1;
end
k=k+1;
end;
zn(j)=0.0;
k=1;
while k<=ne
zn(j)=zn(j)+x0(ne*k+j)^2;
k=k+1;
end
zn(j)=sqrt(zn(j));
k=1;
while k<=ne
x0(ne*k+j)=x0(ne*k+j)/zn(j);
k=k+1;
end
j=j+1;
end
% update running vector magnitudes
k=1;
while k<=ne;
c(k)=c(k)+log(zn(k));
k=k+1;
end;
% normalize exponent
k=1;
while k<=ne
LE(k)=c(k)/(t-t_start);
k=k+1;
end
i=1;
while i<=ne
j=1;
while j<=ne;
x(ne*j+i)=x0(ne*i+j);
j=j+1;
end
i=i+1;
end;
x=transpose(x);
it=it+1;
end
function f=LE_RF_a(t,x,a)
%p is the parameter
f=zeros(16,1);
b=0.4;c=11;d=6;e=130;f1=10;
x=X(1); y=X(2); z=X(3);w=X(4);
Y= [X(5), X(9), X(13), X(17);
X(6), X(10), X(14), X(18);
X(7), X(11), X(15), X(19);
X(8), X(12), X(16), X(20) ];
f(1)=a*y+(0.2+0.2*(abs(w))).*z;
f(2)=b*((w.^2)-13).*z-c*y;
f(3)=-d*x-e*y-f1*z;
f(4)=(z.^2)-w.^2;%Linearized system
Jac=[0 a 0.2+0.2*abs(w) 0.2*w.*z/abs(w);
0 -c b*((w.^2)-13) b*((w*2)-13).*z;
-d -e -f1 0;
0 0 2*z -2*w];
f(5:20)=Jac*Y;
error:>> run_LE_FO_a
p_step =
1.499999999999999e-03
Index exceeds the number of array elements. Index must not exceed 1.
Error in LE_RF_p1 (line 4)
X= [x(4) x(7) x(10);
Error in FDE12>f_vectorfield (line 300)
f = feval(Probl.fdefun,t,y,Probl.param) ;
Error in FDE12 (line 114)
f_temp = f_vectorfield(t0,y0(:,1),Probl) ;
Error in FO_Lyapunov_a (line 21)
[T,Y] = FDE12(q,ext_fcn,t,t+h_norm,[0 0 1 1],h,a);
Error in run_LE_FO_a (line 16)
lp=FO_Lyapunov_a(ne,ext_fcn,0,0.2,1,[0 0 1 1],0.2,1,a)
>>
Voss
Voss on 24 May 2022
This question was about getting the plot to show up, which I believe I've answered.
If you have a question about error messages or anything else, please start a new question.
with out using drawnow() command i want plot
because graph is comming like dots
i want graph like below attachment

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Release

R2021b

Tags

Asked:

on 24 May 2022

Commented:

on 24 Jun 2022

Community Treasure Hunt

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

Start Hunting!