Azzera filtri
Azzera filtri

fminsearch function stops after a few iterations in simulink real time with inverter

1 visualizzazione (ultimi 30 giorni)
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?

Risposte (1)

Dimitri MANKOV
Dimitri MANKOV il 3 Lug 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
  11 Commenti
Torsten
Torsten il 3 Lug 2023
Modificato: Torsten il 3 Lug 2023
As I said: If it works, you have explicit formulas for x(1) and x(2) that you can copy from the editor into a function file. Then it's just like evaluating an equation as
x(1) = a
x(2) = b
Yannic Cullmann
Yannic Cullmann il 3 Lug 2023
This would be great. With your function of meankU2kU0 Matlab does not manage to calculate anything and crashes. With mine I get a warning that it is unable to find explicit solution.

Accedi per commentare.

Categorie

Scopri di più su Manual Performance Optimization in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by