Replace Matlab FCN with Stateflow Chart - Error
1 次查看(过去 30 天)
显示 更早的评论
Hi Guys,
i replaced a working matlab fcn with a stateflow chart. To be honest i didnt expected any errors because it is very simple.
The Model looks like this:
![Stateflow_Obere_Ebene.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224555/image.png)
This is the Matlab fcn:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224550/image.png)
function [w_r,theta_r,iq_ref,motor_state] = fcn(ramp_endspeed,w_r_ramp,theta_r_ramp,w_r_foc,theta_r_foc,Iq_ref_foc,Iq_ramp,pre_motor_state)
if pre_motor_state == 1
w_e = w_e_ramp;
theta_e = theta_e_ramp;
Iq_ref = Iq_ramp;
if w_e_ramp >= ramp_endspeed
motor_state = 2;
else
motor_state = 1;
end
elseif pre_motor_state == 2
w_e = w_e_foc;
theta_e = theta_e_foc;
Iq_ref = Iq_ref_foc;
motor_state = 2;
else
w_e = 0;
theta_e = 0;
Iq_ref = 0;
motor_state = 1;
end
and then i build the statflow with the "classic" setting. But Simulink recommended me to use the "moore" setting.
So this is how it looks like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224551/image.png)
in classic like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224552/image.png)
But the moore stateflow generates this error:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224553/image.png)
And im not understanding it.
Maby this input and output definitions could help u to understand my problem:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224554/image.png)
Inputs and outputs are the same in the Matlab fcn and stateflow. and the logic should be the same.
Thanks in advance.
Best regards
0 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!