Lyapunov Plotting: using 'mesh' and 'meshgrid' with matricies

18 次查看(过去 30 天)
I'm trying to plot a 3d graph of a Lyapunov function of a control system I've created. The function is:
V(x)=xT*P*x
where x is a 2x1 matrix of the errors, e and de/dt:
x = [e;ed];
Therefore x transpose is a 1x2 matrix:
xT = [e, ed];
and the P matrix is 2x2 of constants (ie p1=const,p2=const,p3=const,p4=const):
P = [ p1 p2 ; p3 p4];
"e" and "ed" are a 1xn set of data from my simulation thus V ends up being a 1xn matrix
This is my code right now, I don't know what to do from here:
e = ErrorData.signals.values(:,1);
ed = ErrorData.signals.values(:,2);
for i=1:3420
V(i) = [e(i) , ed(i)] * P * [e(i) ; ed(i)] ;
end
I'm trying to plot (x,y,z) = (e,ed,V) in 3 dimensions but I can't seem to be able make my final vector V suitable for plotting in 3d. for e and ed you can use meshgrid, but I can't get V in the proper form.
I was using this code as an example from ( Lyapunov Example ):
x=[-4:.04:4];
y=x;
[X,Y]=meshgrid(x,y);
z=X.^2 + Y.^2;
mesh(X,Y,z)

采纳的回答

Daniel Cleveland
Daniel Cleveland 2015-4-5
Found the solution. I had to replicate what mesh does.
e = ErrorData.signals.values(:,1);
ed = ErrorData.signals.values(:,2);
[E,ED] = meshgrid(e,ed);
for i=1:3420
for j=1:3420
V(i,j) = [E(i,j) , ED(i,j)] * P * [E(i,j) ; ED(i,j)] ;
end
end

更多回答(2 个)

Daniel Cleveland
Daniel Cleveland 2015-4-4
Hi, Nope, didn't work unfortunately. It doesnt' seem to "connect the dots" per say in the way I want. Here's the result:
  1 个评论
Roger Stafford
Roger Stafford 2015-4-4
That result tells me you should be using dots for your plot marker, not lines. You will then see a crude representation of your desired "surface". Your data is not in suitable form to use with 'surf', which requires a mesh form of input.

请先登录,再进行评论。


Roger Stafford
Roger Stafford 2015-4-4
To get the V you need for plot3, do this:
V = sum(x.*(P*x),1);
Don't do a meshgrid on e and ed for use in plot3. You were probably thinking of 'surf', but that kind of surface plotting is not suitable for your particular problem.
  1 个评论
Intan Utari
Intan Utari 2021-4-1
Dear Sir How are you? Hope you are well and healthy. I have a model of the spread of diphtheria by vaccination and I achieved the linearization of the model through the lyapunov function constructed using the krasovskii method but actually I don't know how to check the stability of the SIR mathematical model of diphtheria spread by vaccination using the Lyapunov stability theorem in Matlab. Would you, if possible help me in this matter, Please. thank you

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Computations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by