How can I find parameters using ode45 function?
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Star Strider
2017년 10월 29일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!