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:
Therefore x transpose is a 1x2 matrix:
and the P matrix is 2x2 of constants (ie p1=const,p2=const,p3=const,p4=const):
"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.
x=[-4:.04:4];
y=x;
[X,Y]=meshgrid(x,y);
z=X.^2 + Y.^2;
mesh(X,Y,z)