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

1 次查看(过去 30 天)
%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