How to get the output variable name in the load() in matlab?
17 ビュー (過去 30 日間)
古いコメントを表示
I want to load an ascii-file using this syntax:
load('10-May-data.dat').
The returned output variable name should be X10_May_data.
Is there a way to get the variable name in matlab?
If I want to use regular expression to do the translation, how can I do it? For example, put an X before any underscores or digits in filename and replaces any other non alphabetic characters with underscores.
Thanks
0 件のコメント
回答 (2 件)
Walter Roberson
2016 年 2 月 3 日
genvarname(regexprep('10-May-data', '-', '_'))
But you should not be using dynamically generated names as the names of variables.
Steven Lord
2016 年 2 月 3 日
The easiest and safest way is to call LOAD with an output argument so you know at the time you write your code what the variable name will be.
mydata = load('10-May-data.dat');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Debugging and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!