Convert five numeric variables into strings in a text file

Hello dear users
I have five variables that are in separate lines in the W2_con file (lines 64_73_626) values (َّAFW-BFW-CFW-CBHE-TCED-EXH2O)
I want to paste these values from number to string in the file

3 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 1 月 4 日
num2str
Mathieu NOE
Mathieu NOE 2021 年 1 月 4 日
hello +
If I understand correctly, you are looiing for a matlab solution to retrieve the data below the headers AFW-BFW-CFW-CBHE-TCED-EXH2O and convert to string ?
mozhgan gholami
mozhgan gholami 2021 年 1 月 4 日
Enter the numeric values of these parameters as a string in a text file, for example (AFW=6.25)

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

回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 1 月 4 日

0 投票

hello again
so this little piece of code will extract the data and display it in the command window.
It assumes that the data will be always available at the same line numbers.
lines = readlines('w2_con.txt');
line64 = split(lines(64,:)); % string
AFW = line64(8); % string
BFW = line64(9); % string
CFW = line64(10); % string
line73 = split(lines(73,:)); % string
CBHE = line73(5); % string
TSED = line73(6); % string
line626 = split(lines(626,:)); % string
EXH2O = line626(3); % string
disp(['AFW = ' , convertStringsToChars(AFW)]); % NB : convert string to char to do horizontal concatenation , then display
disp(['BFW = ' , convertStringsToChars(BFW)]);
disp(['CFW = ' , convertStringsToChars(CFW)]);
disp(['CBHE = ' , convertStringsToChars(CBHE)]);
disp(['TSED = ' , convertStringsToChars(TSED)]);
disp(['EXH2O = ' , convertStringsToChars(EXH2O)]);

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2021 年 1 月 4 日

コメント済み:

2021 年 1 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by