How to run and save variables in a structures?
조회 수: 6 (최근 30일)
이전 댓글 표시
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:
struc.run('filename.m')
Can anyone please help me how to do this?
댓글 수: 0
채택된 답변
KSSV
2022년 10월 18일
run('filename.m')
S = whos ;
save('Test.mat','S')
댓글 수: 1
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', S.name) % this will save the data
strucRun = load('Test.mat') % this will re-load the data into fields of the struct strucRun
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!