How to convert a table to a 2d array
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have 25 csv files that I have I have taken and stored into a temp Table, which was then vertically concatenated into a large table, I want to convert this large table (rpll) into a 2d array so that I can access the row values with a for-loop, what would be the best way of doing this?
rpll=cell(1,data.numberofselected); %Table of all selected csv's ordered by run number aescending
x=cell(1, numel(dir(file_location))); %temp table to store each run which is then concatenated into one large table after this for-loop
for i=1:data.numberofselected
concatenated=strcat(strcat(strcat(file_location,'RUN'),string(data.selected_runs(i))),'.csv');
x{i}=readtable(concatenated);
end
rpll=vertcat(x{:}); %convert into 2d array
for lp = 1:data.numberofselected
i = data.selected_runs(lp);
switch(rpll(3)) ...... %I want to check the 3rd value in every row
0 comentarios
Respuestas (1)
dpb
el 5 de Nov. de 2020
Don't make a cell array of tables to start with...
x=[];
for i=1:data.numberofselected
concatenated=strcat(strcat(strcat(file_location,'RUN'),string(data.selected_runs(i))),'.csv');
x=[x;readmatrix(concatenated)];
end
2 comentarios
dpb
el 5 de Nov. de 2020
Editada: dpb
el 5 de Nov. de 2020
Well, that's what you asked for -- a 2D array. If data have disparate ranges, MATLAB displays scaled values at command line depending upon what you choose for the FORMAT specifier.
We don't have/can't see your data from here so:
- Don't know if the data are actually commensurate to read with readmatrix or not, or
- If are, what are actual data values.
All we know about is what is posted here...if you need more specific help, attach a (section of) a typical file.
ADDENDUM:
NB: The data are storedl at full precision; it is only output format that is affected.
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!