weixin_44227082 2021-10-10 17:19 采纳率: 100%
浏览 73
已结题

在官网给appdesigner的一个例子中中出现simOut.y.signals(2).values,其中y是什么意思?

这是官网例子(


最近在尝试给simulink与appdesigner进行打包成exe,但发现用stateflow回调数据,以及监听器回调数据都无法把simulink文件一起放进去,在官网看到这个,找不到y到底是哪里来的。

try
app.toggleUIC('off', 'Simulating ...');

            % create the simulation input
            simInp = Simulink.SimulationInput('MassSpringDamperModel');%给信号输入仿真文件加一个句柄。

            % set the parameters for this run
            simInp = simInp.setVariable('k',app.StiffnessSpinner.Value);
            simInp = simInp.setVariable('m',app.MassSpinner.Value);
            simInp = simInp.setVariable('b',app.DampingSpinner.Value);
            simInp = simInp.setVariable('x0',app.InitialPositionEditField.Value);%输入变量,也就是改变其中的变量。
            
            % set the model parameters for this run设置运行时间给这个文件。
            stopTimeStr = num2str(app.StopTimeSpinner.Value);
            simInp = simInp.setModelParameter('StopTime', stopTimeStr);

            % set the external input for this run,
            simInp.ExternalInput = app.externalInput();

            % configure simInp for deployment,
            simInp = simulink.compiler.configureForDeployment(simInp);
            % DEBUG TIP: Comment out the line above for faster debug
            % iterations when runnng this app in the MATLAB desktop.
            
            % run
            simOut = sim(simInp);
            
            % extract and plot the results,
 **           t = simOut.y.time;
            yp = simOut.y.signals(1).values;
            yv = simOut.y.signals(2).values;**
            plot(app.PositionUIAxes, t, yp);
            plot(app.VelocityUIAxes, t, yv);
        catch ME
            errordlg(ME.message);    
        end
        app.toggleUIC('on', 'Simulate');
  • 写回答

1条回答 默认 最新

  • 技术专家团-Joel 2021-10-10 18:06
    关注

    你好,这就是sim仿真出来的信号结果,具体看你的结构体解释,simOut是一个结构体变量,存在着输出信号y,然后signals(1)、signals(2)分别表示不同时刻位置和速度信号,取其值画图

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月18日
  • 已采纳回答 10月10日
  • 创建了问题 10月10日

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭