0
0
MATLABdata~20 mins

CSV file handling in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSV Mastery in MATLAB
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Reading CSV with readmatrix
What is the output of this MATLAB code when reading a CSV file with numeric data only?
MATLAB
data = readmatrix('data.csv');
disp(data);
A[1 2 3; 4 5 6; 7 8 9]
BError: File not found
CA cell array with numeric and text data
DA table with variable names
Attempts:
2 left
💡 Hint
readmatrix reads numeric data into a numeric array.
Predict Output
intermediate
2:00remaining
Writing CSV with writematrix
What will be the content of 'output.csv' after running this MATLAB code?
MATLAB
M = [10 20 30; 40 50 60];
writematrix(M, 'output.csv');
AA CSV file with text headers
BA CSV file with one row: '10 20 30 40 50 60'
CAn empty file
DA CSV file with two rows: '10,20,30' and '40,50,60'
Attempts:
2 left
💡 Hint
writematrix writes numeric arrays as CSV rows.
🔧 Debug
advanced
2:00remaining
Reading mixed data CSV with readmatrix
What is the result of this MATLAB code when reading a CSV file with mixed text and numbers using readmatrix?
MATLAB
data = readmatrix('mixed.csv');
AReturns a table with mixed data
BError: Unable to convert text to numeric
CNo error, returns numeric matrix with NaN for text
DError: File not found
Attempts:
2 left
💡 Hint
readmatrix converts non-numeric data to NaN.
Predict Output
advanced
2:00remaining
Reading CSV with readtable and accessing data
Given a CSV file 'people.csv' with columns 'Name,Age,Height', what is the output of this code?
MATLAB
T = readtable('people.csv');
disp(T.Age(2));
AThe entire Age column
BThe age value of the second person in the table
CError: Age is not a field
DThe name of the second person
Attempts:
2 left
💡 Hint
readtable creates a table with column names as fields.
🧠 Conceptual
expert
2:00remaining
Choosing the best function for mixed CSV data
Which MATLAB function is best suited to read a CSV file containing both numeric and text data with headers?
Areadtable
Breadmatrix
Cwritematrix
Dcsvread
Attempts:
2 left
💡 Hint
Consider which function handles mixed data and headers well.