Convert five numeric variables into strings in a text file
Ältere Kommentare anzeigen
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 Kommentare
KALYAN ACHARJYA
am 4 Jan. 2021
num2str
Mathieu NOE
am 4 Jan. 2021
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
am 4 Jan. 2021
Antworten (1)
Mathieu NOE
am 4 Jan. 2021
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)]);
1 Kommentar
mozhgan gholami
am 4 Jan. 2021
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!