Simulink MATLAB Function for loop

1 次查看(过去 30 天)
John
John 2012-1-12
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 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by