How to convert string or chars to string arrays withing for loop?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Element
am 4 Nov. 2019
Beantwortet: Element
am 4 Nov. 2019
How could I convert message to string array withing for loop? Each string in array has to be 4 characters long. For example:
message = 'SOMETEXT';
for i = 1:4:length(message)
%some code here
end
Outcome would be:
out = ["SOME", "TEXT"];
Many thanks
0 Kommentare
Akzeptierte Antwort
KALYAN ACHARJYA
am 4 Nov. 2019
Bearbeitet: KALYAN ACHARJYA
am 4 Nov. 2019
message ='SOMETEXT';
l=1;
for i=1:4:length(message)
result{l}=message(i:i+3);
l=l+1;
end
result
You asked for for loop (specifically)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings 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!