MATLAB Answers

Saving structure data type in Simulink

4 views (last 30 days)
Nishant Kumar
Nishant Kumar on 29 Mar 2020
Answered: Dhananjay Kumar on 31 Mar 2020
I have a MATLAB Function block from which I need to save 10 variables to a file. Every variable has different size. I thought of taking advantage of structure data types. But not been able to save the structure with help of 'To File' block. Moreover, 'save()' function also can't be used in the matlab function block.
Is there any other way I can do that.
Or any way to store all 10 variables in same .mat file.

  3 Comments

Nishant Kumar
Nishant Kumar on 29 Mar 2020
What I am doing actually is loading a structure into the function, then change the variables in it after some operation. I want to overwrite the structure so that it gets updated every time.
Dhananjay Kumar
Dhananjay Kumar on 31 Mar 2020
You want to save the structure or overwrite it?
Nishant Kumar
Nishant Kumar on 31 Mar 2020
Any method would do but I would like to overwrite it.

Sign in to comment.

Answers (1)

Dhananjay Kumar
Dhananjay Kumar on 31 Mar 2020
Try one of these:
2) Export Workspace Variables through model explorer
3) assignin function
4) evalin function

  0 Comments

Sign in to comment.

Products


Release

R2019b