Simulink MATLAB Function for loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have an aircraft model in a Matlab Function which is called from a matlab function.
What I am trying to achieve at the moment is simply getting a while loop set up in the function which outputs the value y every time the while loop is run through.
Currently the while loop does not output the value for each timestep, it simply jumps to the final limit condition.
Please see the code:
function [y,i] = fcn_06(u)
%#codegen
coder.extrinsic('tic','pause')
%Init
AC_Variables = struct('AC_position',double(zeros(3,1)));
i = 1;
%If AC Mode = 1 Then Initialise and Launch
AC_Variables.AC_position = u;
%Loop
while (i <= 200000)
[z] = calculation_06(AC_Variables);
AC_Variables = z;
y = AC_Variables.AC_position;
i = i + 1;
%pause(1)
end
y = AC_Variables.AC_position;
end
function [z]=calculation_06(AC_Variables)
%#codegen
AC_Variables.AC_position = AC_Variables.AC_position + 10;
z = AC_Variables;
end
How do I set it up to output the value at each step?
Thank you in advance.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!