Convert five numeric variables into strings in a text file
Mostrar comentarios más antiguos
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 comentarios
KALYAN ACHARJYA
el 4 de En. de 2021
num2str
Mathieu NOE
el 4 de En. de 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
el 4 de En. de 2021
Respuestas (1)
Mathieu NOE
el 4 de En. de 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 comentario
mozhgan gholami
el 4 de En. de 2021
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!