How can I find parameters using ode45 function?

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;

Answers (1)

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.

Categories

Find more on 수치 적분과 미분 방정식 in Help Center and File Exchange

Asked:

on 29 Oct 2017

Answered:

on 29 Oct 2017

Community Treasure Hunt

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

Start Hunting!