Effacer les filtres
Effacer les filtres

how can I store chars of a cells with different length in a matrix

4 vues (au cours des 30 derniers jours)
fadi awar
fadi awar le 23 Avr 2021
Commenté : fadi awar le 23 Avr 2021
hello,
in a for loop located in a function i was able to get the cell arrays in the following form:
1st: {'R1'} {'R3'} {'R4'}
2nd: {'R1'} {'R3'} {'R6'} {'R5'} {'R4'}
how can i store these outputs in a matrix as:
{'R1'} {'R3'} {'R4'} 0 0
{'R1'} {'R3'} {'R6'} {'R5'} {'R4'}
as the output of my function (or after ending the for loop)

Réponse acceptée

Stephen23
Stephen23 le 23 Avr 2021
C = cell(N,0);
for k = 1:N
tmp = ... the output of your function (cell vector)
C(k,1:numel(tmp)) = tmp;
end
  3 commentaires
Stephen23
Stephen23 le 23 Avr 2021
Following what I wrote in my answer:
ruse = cell(np,0);
for k = 1:np
pk = allp{k};
nodrout = routers(pk);
ruse(k,1:numel(nodrout)) = nodrout;
end
fadi awar
fadi awar le 23 Avr 2021
thank you it worked perfectly
i really appreciate your help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by