fminsearch function stops after a few iterations in simulink real time with inverter
2 views (last 30 days)
Show older comments
Hello all,
I have a problem when running fminsearch in simulink in a real time application. I want to calculate the stress amplitude and the stress angle by fminsearch, so that the unbalance factor kU2, or the norm of kU2 and kU0 becomes as small as possible. These values are then to be passed to an inverter. A part of the code is shown here:
x0 = [u1_abs u1_phi]
fun2 = @(x)kU2kU0berechnung(x,u2,u3,din);
y = fminsearch(fun2,x0);
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
Unfortunately, the fminsearch function stops after a few iterations. I think that this could be because the computer on which the model is running is too slow and then the Matlab function block in Simulink is triggered again before fminsearch is finished.
How can I adjust my model so that fminsearch really comes to a result?
0 Comments
Answers (1)
Dimitri MANKOV
on 3 Jul 2023
Hi Yannic,
I would suggest explicitly defining / checking the tolerances and stopping criteria of the "fminsearch" function in your code to make sure that it executes the correct number of times / until a good solution is found.
I doubt that the issue you're facing is due to the speed of your target machine: with Simulink Real-Time, if a process cannot not be completed before being triggered again, it would result in a CPU overload and the simulation would stop.
I hope this is helpful!
Dimitri
See Also
Categories
Find more on Target Computer Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!