for(a=1;a<=7;a++)
{
input1=10;
input2=12;
input3= input1/input2;
output = (a*input3)-input1-input2;
}
input1,input2和input3来自我构建的Simulink模型。 “ a”变量来自for循环代码,该模型将运行直到a <= 7。如何在Matlab中做到这一点?
答案 0 :(得分:0)
在Simulink图中使用“至工作区”块,以便将结果存储在工作区中。
将for循环更改为:
for(a=1;a<=7;a++)
{
load('system_name.mdl'); %loads the simulink diagram
sim('system_name.mdl'); %runs the simulink diagram
%input1 comes from "To Workspace"
%input2 comes from "To Workspace"
input3= input1/input2;
output = (a*input3)-input1-input2;
}