how to call a matrix(1*43) from model to function ?

조회 수: 3 (최근 30일)
AMAL KRISHNA.S
AMAL KRISHNA.S 2021년 4월 8일
답변: Jan 2021년 4월 8일
%model
rep=ode45(@Obsfun,[t(1) t(end)],[x10 x20 x30 x40]);
figure(1)
plot(rep.x,rep.y(1,:))
grid
figure(2)
plot(rep.x,rep.y(2,:))
grid
%function.
y=rep.y(1,:);% inside function . it is not working. how can i get the matrix value from model to y for inserting it in the equation
% observer equation
x1_dot_hat=(((a1*x2hat*x1hat)/(a2*x1hat+x2hat))-(x1hat*u)-(2*theta*(x1hat-y)));
x2_dot_hat=(((theta^2)*(((-x2hat^2)/(a1*a2*x1hat^2))-((2*x2hat)/(a1*x1hat))-(a2/a1))+2*theta*(x2hat^2/a2*x1hat^2))*(x1hat-y)-((a3*a1*x1hat*x2hat)/(a2*x1hat+x2hat))+(a4*u)-(x2hat*u));
hope you will help as soon as possible.
  댓글 수: 1
Jan
Jan 2021년 4월 8일
The expression "as soon as possible" is not appropriate in a forum, which is supported by voluntary Matlab users.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2021년 4월 8일
You can't. rep is the final answer of the integration. Of course you cannot access it before the integration is ready.
Please explain, why you think you need the output of the integration for the integration.
It supports to understand your problem, if you post the complete code, which runs by copy&paste. Expressions like " %function." are not clear. The general information "it is not working" is less useful than a copy of the error message.
I've inserted some spaces and removed some unneded parentheses:
x1_dot_hat = (a1*x2hat*x1hat) / (a2*x1hat+x2hat) - x1hat*u - 2*theta*(x1hat-y);
x2_dot_hat = (theta^2 * ((-x2hat^2 / (a1*a2*x1hat^2)) - (2*x2hat / (a1*x1hat)) - ...
(a2/a1)) + 2*theta*(x2hat^2 / a2*x1hat^2)) * (x1hat-y) - ...
(a3*a1*x1hat*x2hat) / (a2*x1hat+x2hat) + a4*u - x2hat*u;

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by