How can I find parameters using ode45 function?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm just studying MATLAB... but I have a question.
How can I find parameter 'surface' when using ode45 function
here is the source code. Thanks a lot.
%%This is the function code
function [dx, *surface*] = ode_fun(t,x)
dx = zeros(2,1);
A = [0 1;-1 -(5+1.5*cos(x(1)))*x(2)-1];
B = [0;1];
lamda = 10;
*surface* = x(2) + lamda*(x(1)-5);
u = (5+1.5*cos(x(1)))*x(2)^2 + 5;
dx = A*x + B*u;
end
%%This is the main code
clear all
clc
[t, x] = ode45(@ode_fun,[0 10],[0 0]);
x_desired = 5*ones(length(x(:,1)),1);
figure(1)
plot(t,x(:,1),t,x_desired,'-.','LineWidth',2);
title('feedback linearization');
legend('x1','x desired');
xlabel('Time(s)');
ylabel('Output');
grid on;
figure(2)
plot(t,surface,'LineWidth',2);
title('Sliding Surface');
xlabel('Times(s)');
ylabel('Sliding Surface');
grid on;
0 Kommentare
Antworten (1)
Star Strider
am 29 Okt. 2017
I would calculate it from the solved values for ‘x’:
lamda = 10;
surface = x(:,2) + lamda*(x(:,1)-5);
Unless you are returning event variables, returning extra outputs from ode45 are, to my knowledge, not supported.
0 Kommentare
Siehe auch
Kategorien
Mehr zu 수치 적분과 미분 방정식 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!