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

18 ビュー (過去 30 日間)
Daniel Cleveland
Daniel Cleveland 2015 年 4 月 4 日
コメント済み: Intan Utari 2021 年 4 月 1 日
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 Center および File ExchangeMatrix Computations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by