Simulink and .mat file
조회 수: 4 (최근 30일)
이전 댓글 표시
I'm trying to use a .mat function to call,run and then analyze a Simulink model.I can call and run, but then when I want to do a math operation to the outuput of Simulink it seems my .mat file can't load the data. I'm using a "save to workspace" block to save the data results from simulink.
Can anyone help me with this? Thanks
댓글 수: 1
Andreas Goser
2011년 2월 27일
From the words, I'd says you mean a MATLAB file, a function or script AKA M-File. MAT files are data files. Please clarify. I will write an answer based on the MATLA file assupmtion.
답변 (2개)
Andreas Goser
2011년 2월 27일
The description fits to problems where a user runs simulations with the SIM command through a MATLAB code and wonders where the data ends up.
The To Workspace block writes into the MATLAB base workspace. Depending on hoe you work in MATLAB, you may use a different worksapce and thus don't find the data.
You shold also look at the SIM command and the option to retrieve your simulation results through the command.
Paulo Silva
2011년 2월 27일
The question has a bunch of errors and there isn't reliable information about what error occurs so I will try to guess:
1. If you just want to perform some math operations to the variable dTireFR in the workspace after the simulation has finished and there's some error message please copy and paste it in your question so we can see exactly what it is and in what line. The code you used is also welcome so we can help you. Now this is a wild guess, you are trying to do some calculations but you don't take into account the size and type of the variable, you could be also typing the name of the variable wrong.
2. In case you want to use functions that you made you must provide it as an argument like this myfunction(dTireFR) Another way but less recommended is to define dTireFR as global in the workspace and functions you want to use that variable. Yet another way, import the variable to your function like this assignin('caller','dTireFR',dTireFR) There are even more ways to do it but please do provide the variable as argument.
댓글 수: 10
Paulo Silva
2011년 2월 28일
[tout,x,y1,y2,y3...yn] = sim(gcs)
y1 is the variable that gets the data from the first output port
y2 is the variable that gets the data from the second output port
y3 is the variable that gets the data from the third output port
...
yn is the variable that gets the data from the nth output port
set_param('ModelName/ConstantBlockName','Value','2') works for me
set_param('ModelName/ConstantBlockName','value','2') also work good
You might have something wrong with the names, I don't know.
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!