0
0
MATLABdata~20 mins

Numeric types (double, single, integer) in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Numeric Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of mixed numeric type operations
What is the output of this MATLAB code?
a = single(5.5); b = int32(2); c = a + b; disp(class(c)); disp(c);
MATLAB
a = single(5.5);
b = int32(2);
c = a + b;
disp(class(c));
disp(c);
A
int32
7
B
double
7.5
C
single
7.5
D
single
7
Attempts:
2 left
💡 Hint
Remember MATLAB converts integer types to single or double when mixed with floating types.
Predict Output
intermediate
2:00remaining
Integer division result type
What is the output of this MATLAB code?
x = int16(7); y = int16(2); z = x / y; disp(class(z)); disp(z);
MATLAB
x = int16(7);
y = int16(2);
z = x / y;
disp(class(z));
disp(z);
A
int32
3
B
double
3.5
C
int16
3
D
single
3.5
Attempts:
2 left
💡 Hint
Division of integer types returns double in MATLAB.
🔧 Debug
advanced
2:00remaining
Identify the error in numeric type conversion
What error does this MATLAB code produce?
a = int8(130); disp(a);
MATLAB
a = int8(130); disp(a);
ANo output, infinite loop
BError: Value exceeds int8 range
CWarning: Data truncated
DNo error, displays -126
Attempts:
2 left
💡 Hint
int8 can only store values from -128 to 127.
🧠 Conceptual
advanced
1:30remaining
Memory size of numeric types
Which numeric type uses the least memory in MATLAB?
Aint8
Bdouble
Csingle
Dint32
Attempts:
2 left
💡 Hint
Check the number of bytes each type uses.
Predict Output
expert
2:30remaining
Result of mixed numeric array operations
What is the output of this MATLAB code?
A = single([1.5, 2.5]); B = int16([2, 3]); C = A .* B; disp(class(C)); disp(C);
MATLAB
A = single([1.5, 2.5]);
B = int16([2, 3]);
C = A .* B;
disp(class(C));
disp(C);
A
single
3.0 7.5
B
double
3.0 7.5
C
int16
3 7
D
single
3 7
Attempts:
2 left
💡 Hint
Element-wise multiplication with mixed types converts integers to single.