Speed up string Assembly
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonas Widmer
am 14 Apr. 2018
Beantwortet: Jonas Widmer
am 15 Apr. 2018
Hi all,
Question: I try to assamble strings with the following loop (ch_empty10 = ' ', and db_Value(i) = e.g. 4.1563):
for i = 1:100000
ch_String = [ch_String, ch_empty10(1:10-length(num2str(db_Value(i)))),num2str(db_Value(i))] %(-> would result in ' 4.1563')
end
In my application I have >100'000 different db_Values and all need to be assembled the same way and are combined to one string. Is there somehow a way that I can avoid using a loop that goes thru all nodes to speed up the process.
I hope I formulated the question clear enough. Thanks for your help! Best, J
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 15 Apr. 2018
Bearbeitet: Walter Roberson
am 15 Apr. 2018
ch_String = sprintf('%10.4f', db_Value);
No loop. This does everything at the same time.
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!