Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

New to matlab. Trying to code with excel.

3 Ansichten (letzte 30 Tage)
Aris Desai
Aris Desai am 11 Okt. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 under each column/name. I am trying to loop this so that i can have multiple columns if necessary.
Basically this,
Name1 Name2.............(etc).....
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

Antworten (1)

Turlough Hughes
Turlough Hughes am 11 Okt. 2019
[data,varnames]=xlsread('myfilename.xlsx')
sumdata=sum(data); % sumation of columns
T=array2table(sum(data),'VariableNames',varnames) % Table of results plus corresponding column title
If your file is located in your working directory you can refer you can read it in as above. Otherwise, you will need to specify the full address of your file e.g.
'C:\...\myfilename.xlsx'
  1 Kommentar
Aris Desai
Aris Desai am 16 Okt. 2019
Thank you this works!!! Is there a way to do this without using sumdata and array2table. I know its harder but I wanted to learn how to make a loop to possibly return the same data?
Thanks

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by