How to select specific data from an excel file which consists of more than 1 row and more than 1 column of data

조회 수: 3 (최근 30일)
I am trying to programme a way where the user can select a specific data from my excel file. The excel file consists of 13rows and 6 columns with the first collumn and first row as headings. I want to make it so the user selects heading 1 then selects heading 2 and then print out the value that corresponds to the 2 selected headings.
  댓글 수: 1
dpb
dpb 2021년 12월 1일
Look at
doc uigetfile
doc sheetnames
doc listdlg
doc readtable
Those and examples given for using them should let you put together a tool pretty quickly...

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

답변 (1개)

Rishabh Singh
Rishabh Singh 2021년 12월 7일
Hi,
Considering the excel data as in below,
table = readtable("Example.xlsx"); % read excel file from the directory
%access the heading
heading1 = table.X1;
heading2 = table.X2;
Hope this helps.
  댓글 수: 2
Dedong Huang
Dedong Huang 2021년 12월 10일
Hello,
Thank you for the response. I just tried it for my code, but it returns this message:
"Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating
variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Error using tester (line 4)
Unrecognized table variable name 'Temp'."
I have checked my Excel file and the titles appear to be correct.
Can you help with this?
dpb
dpb 2021년 12월 10일
Not without seeing the actual complete code and the error in context -- and attaching the file would never hurt; we can't really guess what the variable names might be...
At a minimum show us what
table = readtable("YourFile.xlsx");
table.Properties.VariableNames
returns.

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

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by