フィルターのクリア

How to read data from excel to a cell?

4 ビュー (過去 30 日間)
Honey
Honey 2021 年 11 月 10 日
コメント済み: Honey 2021 年 11 月 12 日
Hi,
I have an excel file which is containing [precipitation year month day] respectively. I want to read these data to a cell file with N struct which N is the number of the years in the excel file and each struct has x*y matrix which x is the number of months of a year and y is the number of days in each month.
I am not a professional in matlab and need some hints for starting this code. Thanks for everyone who can help me.
attached you can find an example of my excel file and cell file.
  2 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 11 月 10 日
I would like to know more about how you intend to use the data. Reading into a structure and cell would not be my first choice here.
Cris LaPierre
Cris LaPierre 2021 年 11 月 10 日
Moved @Honey's response to be a comment instead of an answer
@Cris LaPierre I am doing a comparative work. I have to compare these data to a set of cell data. So It is better to arrange my excel in a cell too.

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

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 11 月 10 日
You can get the data from *.xlsx with a few different data import fcns of matlab. Here are two most recommended data import fcns, e.g.:
% D1 is a matrix:
D1 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/796554/Data.xlsx');
% D2 is a table:
D2 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/796554/Data.xlsx');
XY1 = D1(:,3).*D1(:,4); % Calculated results from readmatrix() data
XY2 = D2.Month.*D2.Day; % Calculated results from readtable() data
You may also consider data import using xlsread(), uiimport(), etc, which are bit slower.
  1 件のコメント
Honey
Honey 2021 年 11 月 12 日
Thank you Sulaymon Eshkabilov . But it is not what I meant.

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

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by