how to read the data of type a*b?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahendra Yadav
am 7 Jan. 2025
Kommentiert: Star Strider
am 7 Jan. 2025
I have input dataset of following type:
'1*5 5*4 6 8 3 12 -5 9*0 7*-1'
how can I read each value and store it in nice format.
2 Kommentare
Stephen23
am 7 Jan. 2025
"how can I read each value and store it in nice format."
What is the expected output for that example?
Akzeptierte Antwort
Weitere Antworten (1)
Star Strider
am 7 Jan. 2025
Taking a wild guess that the ‘multiiplicatiion’ operators are equivalent to the ‘power-of-10’ indicator ‘E’ or ‘e’, first use strrep then strsplit then str2double (here done in a single line) —
format shortG
str = '1*5 5*4 6 8 3 12 -5 9*0 7*-1';
num = str2double(strsplit(strrep(str, '*', 'E'), ' '))
I have no iidea if this is actually correct.
.
2 Kommentare
Star Strider
am 7 Jan. 2025
In that instance, then just this —
format shortG
str = '1*5 5*4 6 8 3 12 -5 9*0 7*-1';
num = str2double(strsplit(str, {' ','*'}))
Avoid all tthe complications.
I didn’t see this earlier because I was sleeping. I’m in the UTC-7 timezone.
.
Siehe auch
Kategorien
Mehr zu Standard File Formats finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!