Combining matrices of different sizes

Hello I'm trying to combine multiple matrices of different sizes which are extracted from each .csv files.
Sat_total = NaN(1440 , 3*30);
sat = readtable('Place-MyHome-Sensor-Myphone-To-Satellite-PRN_32_41328 AER.csv');
[Sat_temp] = sat_tot(sat);
Sat_total(1:length(Sat_temp(:,1)), 1:3) = Sat_temp;
sat = readtable('Place-MyHome-Sensor-Myphone-To-Satellite-PRN_31_29486 AER.csv');
[Sat_temp] = sat_tot(sat);
Sat_total(1:length(Sat_temp(:,1)), 4:6) = Sat_temp;
sat = readtable('Place-MyHome-Sensor-Myphone-To-Satellite-PRN_30_39533 AER.csv');
[Sat_temp] = sat_tot(sat);
Sat_total(1:length(Sat_temp(:,1)), 7:9) = Sat_temp;
sat = readtable('Place-MyHome-Sensor-Myphone-To-Satellite-PRN_29_32384 AER.csv');
[Sat_temp] = sat_tot(sat);
Sat_total(1:length(Sat_temp(:,1)), 10:12) = Sat_temp;
...
( I used [Sat_temp] = sat_tot(sat) to modify tables been extraced to matrices)
As you can see, i'm trying to combine n*3(n differs for each of them) matrices in row.
Please let me know if there are any better solutions, not by typing them manually.
Thank you in advance.

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 10 de Oct. de 2020
I would do something like this
% list all file names. You may use dir() function to get them automatically
filenames = {'Place-MyHome-Sensor-Myphone-To-Satellite-PRN_32_41328 AER.csv', 'Place-MyHome-Sensor-Myphone-To-Satellite-PRN_31_29486 AER.csv', ...
Sat_total = cell(1, numel(filenames))
for i = 1:numel(filenames)
sat = readtable(filenames{i});
Sat_total{i} = sat_tot(sat);
end
Sat_total = [Sat_total{:}];

4 comentarios

aero123
aero123 el 11 de Oct. de 2020
Thank you for your help.
But, for the end of the code. With my understand, you're trying to make matrix by arranging them in a row.
But each matrices in the cell have different length which make it unable to arranging them.
Could you help me with it?
Ameer Hamza
Ameer Hamza el 11 de Oct. de 2020
Ok. I get it. Do you want to append them with NaNs if they are less then 1440? Also, the attached image is empty.
aero123
aero123 el 11 de Oct. de 2020
I have solved it :) Thank you very much
Ameer Hamza
Ameer Hamza el 11 de Oct. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 10 de Oct. de 2020

Comentada:

el 11 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by