How can I set up that a Matlab function in Simulink should first finish calculating and then get the new input values?

3 ビュー (過去 30 日間)
Hello all,
I think that my Matlab function in Simulink Real Time somehow fails to calculate the output values first and gets new input values only afterwards. So it is overriding the output??? It uses fminsearch to calculate the values.
iter = 199;
fun2 = @(x)kU2kU0berechnung(x,u2,u3,din);
options = optimset('TolFun',1e-14,'TolX',1e-14,'MaxIter',iter);
y = fminsearch(fun2,x0,options);
function meankU2kU0 = kU2kU0berechnung(x,u2,u3,din)
u123 = [x(1)*exp(1i*x(2)/360*2*pi);u3;u2];
a = exp(1i*120/360*2*pi);
a2 = a^2;
T = [1 1 1; a2 a 1; a a2 1];
umg0 = T\u123;
meankU2kU0 = sqrt((abs((umg0(2)/umg0(1))*100)^2+((1-din)*abs((umg0(3)/umg0(1))*100))^2)/2);
end
uabs = y(1);
uphi = y(2);
I get the idea because I calculate the output values once with a real time measurement and a second time for control with the data set from the real time measurement start another calculation in Simulink (not real time). In the attachment you can see the results for uabs. The image with the yellow line jumping up and down is the real-time measurement and the image with the stable yellow line is the subsequent calculation.
You can see that the data jumps somehow.
Maybe someone can help me or had this problem before.

回答 (1 件)

Saksham
Saksham 2023 年 8 月 22 日
Hi Yannic,
I understand that you want MATLAB function block to receive input only after it has processed the previously received input.
For this use case, “Rate Transition” block might be helpful. Below is the link to its documentation:
I hope the above shared resource will be helpful to you.
Sincerely,
Saksham

カテゴリ

Help Center および File ExchangeTarget Computer Setup についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by