Creating automated multiple variables to store excel table in a loop

조회 수: 6 (최근 30일)
NAMAN JAIN
NAMAN JAIN 2020년 10월 16일
댓글: NAMAN JAIN 2020년 10월 21일
Hi all,
So I have got multiple excel files(.xlsx) named as "day 1 , day 2 , day 3.......day 30" in the order of 288x29. What I want is for Matlab to automatically generate variables in a sequence like "data_day1, data_day2.....data_day30" to store the data from the excel file as a table in a loop, so I can use values from the table to do more calculations.
I am a self-taught newbie and any help would be greatly appreciated!!!!!
thanks for your time,
cheers
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2020년 10월 16일
hi
could you share some execl file to see how to proceed ?
how do you want to merge the excel file data together ?
Sudhakar Shinde
Sudhakar Shinde 2020년 10월 16일
example:
Day1.xlsx , Day2.xlsx and Day3.xlsx
For i:1:3
data_day(i) = readtable('Day',num2str(i),'.xlsx');
end

댓글을 달려면 로그인하십시오.

채택된 답변

Gaurav Garg
Gaurav Garg 2020년 10월 19일
Hi Naman,
You can use readtable function to create table from an excel file and then create a loop e.g. -
for i = 1:3
data_day(i) = readtable('Day',num2str(i),'.xlsx');
end
The name of the file within readtable function should be a string. So, we convert i to a string and then append it to Day and extension .xlsx before passing it as an argument to readtable function.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by