how to input data into an array from csv files in a for loop
Afficher commentaires plus anciens
I have some csv files broken up and I want to concatenate them all into one big array but I dont want to input them one by one like the commented out code, is there a way to do this? Thank you
Birth1 = 5.6;
Death1 = 1;
for i = 1:17
na = sprintf('Birth2_%g',i);
str = sprintf('Birth2_Cons_muj_%g_bj_%g_Part_%g.csv',Death1,Birth1,i);
na = readmatrix(str);
end
% Birth2_1= readmatrix('Birth2_Cons_muj_1_bj_5.6_Part_1.csv');
% Birth2_2= readmatrix('Birth2_Cons_muj_1_bj_5.6_Part_2.csv');
Birth2 = [Birth2_1 Birth2_2 Birth2_3 Birth2_4 Birth2_5 Birth2_6 Birth2_7 Birth2_8 Birth2_9 Birth2_10 Birth2_11 Birth2_12 Birth2_13 Birth2_14 Birth2_15 Birth2_16 Birth2_17];
When I run the above code I get an error:
Unrecognized function or variable 'Birth2_1'.
Error in concatenating_matrices (line 14)
Birth2 = [Birth2_1 Birth2_2 Birth2_3 Birth2_4 Birth2_5 Birth2_6 Birth2_7 Birth2_8 Birth2_9 Birth2_10 Birth2_11 Birth2_12 Birth2_13 Birth2_14 Birth2_15 Birth2_16 Birth2_17];%
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!