How to run and save variables in a structures?

조회 수: 1(최근 30일)
MP 2022년 10월 18일
답변: MP 2022년 10월 19일
I would like to run a matlab code using:
run('filename.m'); % it contains numerous variables in it.
I would like to save all these variables into a structure when I run it.
something like:'filename.m')
Can anyone please help me how to do this?

채택된 답변

KSSV 2022년 10월 18일
S = whos ;
  댓글 수: 1
Les Beckham
Les Beckham 2022년 10월 18일
This just saves the result of the whos command (variable names, sizes, types, etc.) it doesn't actually save the data.
save('Test.mat', % this will save the data
strucRun = load('Test.mat') % this will re-load the data into fields of the struct strucRun

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

추가 답변(1개)

MP 2022년 10월 19일
Thank you so much @KSSV and @Les Beckham


Find more on Variables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by