how to properly use num2str with string input for load or title funtions.

26 ビュー (過去 30 日間)
Yihao Cui
Yihao Cui 2019 年 8 月 14 日
コメント済み: Neuropragmatist 2019 年 8 月 14 日
Annotation 2019-08-14 111931.png
Any idea why the numerical value isn't properly converted into a string?

採用された回答

Yihao Cui
Yihao Cui 2019 年 8 月 14 日
the solution is to include square brackets with the load function:
load(['your string','num2str', 'here']);
  1 件のコメント
Neuropragmatist
Neuropragmatist 2019 年 8 月 14 日
In future you might want to spend a little time trying to solve the problem yourself, then I wouldn't waste time answering a question you solved before I could even post the answer.

サインインしてコメントする。

その他の回答 (1 件)

Neuropragmatist
Neuropragmatist 2019 年 8 月 14 日
I'm guessing the files you want to load are named something like: 'GST_amorph_P900_Reflection'?
If that's the case you need to make the filename a single string using square brackets:
load(['GST_amorph',num2str(P_names(i)),'_Reflection'])
You will have to do something similar with the line after this one too.
Hope this helps,
M.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by