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
2021 年 1 月 4 日
num2str
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
2021 年 1 月 4 日
回答 (1 件)
Mathieu NOE
2021 年 1 月 4 日
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 Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!