フィルターのクリア

How to convert a table to a 2d array

3 ビュー (過去 30 日間)
waleed khalid
waleed khalid 2020 年 11 月 5 日
編集済み: dpb 2020 年 11 月 5 日
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

回答 (1 件)

dpb
dpb 2020 年 11 月 5 日
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 件のコメント
waleed khalid
waleed khalid 2020 年 11 月 5 日
This obfuscates my data to a mix of 0's and 0.0010's.
dpb
dpb 2020 年 11 月 5 日
編集済み: dpb 2020 年 11 月 5 日
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:
  1. Don't know if the data are actually commensurate to read with readmatrix or not, or
  2. 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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by