필터 지우기
필터 지우기

saving variables in workspace to m file

조회 수: 28 (최근 30일)
Aditya
Aditya 2016년 8월 5일
편집: dpb 2016년 8월 5일
Hi I have long list of variables in my workspace which I would like to save in a m file, both names and corresponding values, can any one help please? thank you
  댓글 수: 3
Stephen23
Stephen23 2016년 8월 5일
@Aditya: why not just save the data using one the methods that are easy to use and that are used by most MATLAB users? You can read about them here:
Probably the easiest would be to use mat files.
Saving variables to an Mfile will not be simple.
Konark Kelaiya
Konark Kelaiya 2016년 8월 5일
Yes, saving into .mat is easy and recommend , because you will not achieve anything then just variable list and corresponding values.
If you have to use those variables and values other than MATLAB then it would be nice to save in some text file.
Ofcourse there is a way to save all variables from workspace to M-file. If you want that you can create few lines of code with
1. Get list of variables using "who" command.
2. Then use "eval" to get values for corresponding variable Name.
3. Once you get value create a string like ['Var_Name = [Values]'] and write one-by-one in M-file

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by