필터 지우기
필터 지우기

Simulink workspace

조회 수: 4 (최근 30일)
Clinton Cathey
Clinton Cathey 2011년 6월 23일
All-
I have a simulink model with many of the simulation and block parameters defined by variables. I am trying to create the variables and call the model (with the 'sim' command) in a function. However, the model doesn't seem to look for the variables in the function's workspace.
Would just as soon not make the variables global or add them to the base level workspace. How can I add the variables to the model's workspace or have the model reference the function's workspace?
Thanks CC
-------------------------------------------------
A simplified version of my function is:
SimAnalysis = function(controller,plant,Tmax,Ts)
% controller is a structure needed by the mdl that contains the parameters that define my controller
% plant is a structure needed by the mdl that contains the parameters that define my plant
% Tmax is a scalar that is the stop time of the model in seconds
% Ts is a scalar that is the sample period of the model in seconds
a = 1; % other parameters needed by the simulation, but fixed for this case
b = 2;
c = 3;
sim('my_model.mdl')
SimAnalysis = max(logsout.x.Data); % stand in for my analysis

채택된 답변

Clinton Cathey
Clinton Cathey 2011년 6월 23일
Paulo-
Thanks - that got me most of the way there. In addition to the destination workspace, I also needed a source workspace:
CC
opts = simset('DstWorkspace','current','SrcWorkspace','current');
sim('my_model.mdl',[], opts)
  댓글 수: 1
Paulo Silva
Paulo Silva 2011년 6월 23일
Sorry for the mistake, I copied the code from a previous answer but forgot to change DstWorkspace to SrcWorkspace

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Paulo Silva
Paulo Silva 2011년 6월 23일
change the workspace of your simulation or define the parameters of the simulation or blocks with set_param, here's the simple solution
opts = simset('DstWorkspace','current')
sim('my_model.mdl',[], opts);

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by