필터 지우기
필터 지우기

Log Simulink simulation data to structure element

조회 수: 3 (최근 30일)
Gergely Hunyady
Gergely Hunyady 2019년 7월 26일
답변: David K. 2019년 7월 26일
Hy,
I am looking for solutions to write simulation data to an existing structure.
I have the following structure:
struct.PNG
And the following system (yet just with constant values):
system.PNG
So my goal is to save the steering angles (on the right) to "CT.Front_Wheel.Angle" but when i write this in the "To Workspace" box, it gives me the following error:
error.PNG
I tried with log and bus output, but it gives me a new dataset, and using the same name does not help.
Thanks for your help in addition.
Gergely Hunyady

채택된 답변

David K.
David K. 2019년 7월 26일
The way that I would do it is this. In your main simulink model, right click anywhere go to ModelProperties -> Callbacks -> StopFnc and you get a blank area you can code into. What this area does is it runs the code there every time the model finishes. So you are putting the data into the struct as if you typed these commands after each run, but this does it automatically.
Then put in there the code
CT.Front_Wheel.Angle = toWorkspaceVariableName;
And repeat that for however many variables you want to put in the struct.
example.png

추가 답변 (0개)

카테고리

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