The best approach to name .mat file when saving so can be loaded easily by calling

조회 수: 1 (최근 30일)
I am saving multiple .mat files has that each are for specific parameters for example mat file number 1 has a=1, b=2, c=3 and mat file number 2 has a=2, b=5, c=10, and so on.
What type of naming do you recommend so that loading later would be easier?
For example if I name .mat file as:
a_1_b_2_c_3
or
a1_b2_c3
or
abc_123
and ...
  댓글 수: 1
Stephen23
Stephen23 2019년 10월 11일
"What type of naming do you recommend so that loading later would be easier?"
The filename makes no difference to load.
How do you need it to be "easier" ?

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

채택된 답변

Walter Roberson
Walter Roberson 2019년 10월 10일
abc_123 format cannot handle distinguishing which of the parameters is multiple digits. For exampe is abc_1234 the case of a=1, b=2, c=34, or is it a=1, b=23, c=4, or is it a=12, b=3, c=4 ?
a1_b2_c3 requires either that the variable name is always a single character, or else that you search each of the part to find the last string of digits -- to break apart the 2 from the b2 for example. This could present difficulties if any of the variable names end in a digit.
a_1_b_2_c_3 permits easy splitting of the string by _ character and permits flexibility in parameter values, but does assume that none of the variable names includes an underscore.
  댓글 수: 4
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 10월 11일
@Walter Roberson and when I want to call them, how can I ask the software to distingush based on the =? I mean later I need to call and load these saved files and I need the software to extract some info form the saved name, take a=1 as variable, b=-2 as variables,...
Walter Roberson
Walter Roberson 2019년 10월 11일
You can use regexp() 'split' or you use regexp() to create named tokens

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

추가 답변 (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