New to Matlab. Reading excel file problem?

2 ビュー (過去 30 日間)
Aris Desai
Aris Desai 2019 年 10 月 10 日
コメント済み: Aris Desai 2019 年 10 月 11 日
I am new to matlab and I am trying to read an excel file. This is what I need it to read. Each column will be a seperate name listed in the first row. Below each column has a "1" extending for x amount of rows. I am trying to store the number of those "1's" as the amount per columns
Basically this,
Name1 Name2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1
1
1
1
1

採用された回答

Maz M. Khansari
Maz M. Khansari 2019 年 10 月 10 日
The following script will do what you need. Remove semicolon to get the output. provide the name of your excel file to xlsread function.
[values,header] = xlsread('x.xlsx'); % read excel file
col_1 = values(:,1); % get values of first column
col_1 = col_1(~isnan(col_1)); % remove nans, if any
numel(col_1); % count number of values in the first column
col_2 = values(:,2); % get values of second colum
col_2 = col_2(~isnan(col_2)); % remove nans, if any
numel(col_2); % count number of values in the first column
  1 件のコメント
Aris Desai
Aris Desai 2019 年 10 月 11 日
Thank you.
Is there a way to loop it where if i have multiple columns with different amount of numbers i can store it in that column name andhave it post in the name of the column and under it the amount of numbers.
Name1 Name2 Name3 ..........(etc)
1 1 1
1 1 1
1 1 1
1 1 1
1 1
1 1
1
1
1

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by