필터 지우기
필터 지우기

Import XLSX in MATLAB using input() and xlsread()?

조회 수: 11 (최근 30일)
Sergio
Sergio 2024년 1월 24일
댓글: Sergio 2024년 1월 24일
Hi, I am trying to create code for a script file in which Matlab's function input() is used to read the name of an excel file whose data is then read in using the function xlsread().
The thing I don't understand is why there is a need for input() when we have xlsread()?
My attempt is, however it doesn't open the XLSX file.
I think the input() part is vital, but how are these used together?
Thanks
xlsread(test.xlsx)
  댓글 수: 2
Enrique
Enrique 2024년 1월 24일
Morning Sergio,
First thing you need to try is to enter your excel file as a string
Now you have
xlsread(test.xlsx)
And you would like
xlsread('test.xlsx')
Second thing is that matlab does not recommend xlsread anymore. Use readtable instead. Example:
T = readtable("patients.xls",ReadRowNames=true);
T(1:5,1:4)
Hope it helps, if you need anything else we can go further.
Best regards,
Enrique
Sergio
Sergio 2024년 1월 24일
Thanks Enrique!!

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

채택된 답변

Dyuman Joshi
Dyuman Joshi 2024년 1월 24일
You should use the more robust readmatrix or readtable.
There is no need for using input(). Directly specify the filename to the call -
data = readmatrix('test.xlsx')
%or
data = readtable('test.xlsx')
Refer to the documentation pages linked for more information.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by