for loop append variable
Mostra commenti meno recenti
i'd like to append variable n0 to n1
but this code made just last variable
Thanks!
leng=length(list)
n0=[]
for i=1:leng
nl=list(i).name
end
6 Commenti
Stephen23
il 18 Feb 2022
No need to use a loop:
{list.name} % to place into a cell array
[list.name] % to concatenate together
il147
il 18 Feb 2022
vertcat(list.name) % concatenate elements
[list.name].' % concatenate elements
{list.name}.' % place elements into a cell array
il147
il 18 Feb 2022
Stephen23
il 18 Feb 2022
That is why I showed you this approach:
{list.name}.'
Much simpler than a loop.
il147
il 18 Feb 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!