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 Kommentare

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 ?
Enter the numeric values of these parameters as a string in a text file, for example (AFW=6.25)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Mathieu NOE
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)]);

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 4 Jan. 2021

Kommentiert:

am 4 Jan. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by