Storage columns of data from excel sheet on matlab table cell

조회 수: 1 (최근 30일)
Kaiyuan
Kaiyuan 2024년 9월 3일
답변: Voss 2024년 9월 3일
I want to create a matlab table where each cell can store sequences of data as shown by image 1 and image 2.
The aim is to extract the values of a single column from excel sheet (Shown on image 3) and store these values on a single cell of matlab table. The process will be repeated until all the excel columns are stored on matlab table cells.
For example, the column A data from excel sheet will be stored at cell (1,1) of matlab table, the column B data from excel sheet will be stored at cell (2,1) of matlab table, the column C data from excel sheet will be stored at cell (3,1) of matlab table and so on.
The excel sheet is attached with this questions.
Could our friends help me with that?
Image 1
Image 2
Image 3

채택된 답변

Voss
Voss 2024년 9월 3일
"I want to create a matlab table" but you show a cell array. These methods create a cell array as you describe:
Method 1:
T = readtable('Wind_Speed_Data_2023.xlsx','VariableNamingRule','preserve');
N = size(T,2);
C = cell(N,1);
for ii = 1:N
C{ii} = T.(ii);
end
disp(C)
{8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double}
Method 2:
T = readtable('Wind_Speed_Data_2023.xlsx','VariableNamingRule','preserve');
tmp = varfun(@(x){x},T);
C = tmp{:,:}.';
disp(C)
{8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double} {8759x1 double}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by