0
0
MATLABdata~10 mins

Excel file reading and writing in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read data from an Excel file named 'data.xlsx'.

MATLAB
data = readtable('[1]');
Drag options to blanks, or click blank then click option'
Adata.csv
Bdata.xlsm
Cdata.txt
Ddata.xlsx
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong file extension like .csv or .txt.
Forgetting to put the filename in quotes.
2fill in blank
medium

Complete the code to write the table 'T' to an Excel file named 'output.xlsx'.

MATLAB
writetable(T, '[1]');
Drag options to blanks, or click blank then click option'
Ainput.xlsx
Boutput.xlsx
Cresults.csv
Ddata.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using a filename with the wrong extension like .csv or .txt.
Not putting the filename in quotes.
3fill in blank
hard

Fix the error in the code to read only the sheet named 'Sheet2' from 'data.xlsx'.

MATLAB
data = readtable('data.xlsx', 'Sheet', [1]);
Drag options to blanks, or click blank then click option'
A'sheet2'
B2
C'Sheet2'
DSheet2
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a string for the sheet name.
Not quoting the sheet name.
Using wrong case like 'sheet2' instead of 'Sheet2'.
4fill in blank
hard

Fill both blanks to read data from 'data.xlsx' sheet 'Sales' and write it to 'summary.xlsx'.

MATLAB
data = readtable('[1]', 'Sheet', '[2]');
writetable(data, 'summary.xlsx');
Drag options to blanks, or click blank then click option'
Adata.xlsx
Bsummary.xlsx
CSales
DSheet1
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the filenames or sheet names.
Using wrong sheet name like 'Sheet1' instead of 'Sales'.
5fill in blank
hard

Fill all three blanks to read 'Sheet1' from 'input.xlsx', select rows where 'Age' > 30, and write to 'filtered.xlsx'.

MATLAB
data = readtable('[1]', 'Sheet', '[2]');
filtered = data(data.[3] > 30, :);
writetable(filtered, 'filtered.xlsx');
Drag options to blanks, or click blank then click option'
Ainput.xlsx
BSheet1
CAge
DAgeGroup
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sheet name or filename.
Using a wrong column name for filtering.
Not using the correct syntax for filtering rows.