How to associate a variable according to the .mat file name

1 回表示 (過去 30 日間)
FG
FG 2020 年 10 月 7 日
回答済み: Gaurav Garg 2020 年 10 月 14 日
Hi all.. I wanna know if I could associate a variable according to a file name.. ? Example:
Mat File Names are:
Load 1 Q 1 Nt1
Load 1 Q 1 Nt2
Load 1 Q 1 Nt3
.
.
.
I want to write a code that changes with Nt..If Nt is 1 take the value a, if Nt is 2 take the value b.. likewise
Thanx
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 7 日
Use regexp() or indexing or extractBefore() and extractAfter() to pull apart the file name.
If the variable you want is the only one in the file, then the method is a bit easier.
FG
FG 2020 年 10 月 7 日
Just interested in Nt.. Others are out of my concern

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

回答 (1 件)

Gaurav Garg
Gaurav Garg 2020 年 10 月 14 日
Hey,
I assume that you already know the value of 'Nt' and stored the value in nt.
char (nt + 'a' - 1)
would return you the final answer you want.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by