0
0
MATLABdata~10 mins

Why string operations are essential in MATLAB - Test Your Understanding

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

Complete the code to create a string variable named greeting.

MATLAB
greeting = [1];
Drag options to blanks, or click blank then click option'
AHello, world!
B'Hello, world!'
Chello world
D"Hello, world!"
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes instead of single quotes for strings in MATLAB.
2fill in blank
medium

Complete the code to concatenate two strings str1 and str2.

MATLAB
result = [[1], str2];
Drag options to blanks, or click blank then click option'
A'str1'
Bstr2
C'str2'
Dstr1
Attempts:
3 left
💡 Hint
Common Mistakes
Putting variable names inside quotes, which makes them literal strings.
3fill in blank
hard

Fix the error in the code to convert a string to uppercase.

MATLAB
upperStr = [1](inputStr);
Drag options to blanks, or click blank then click option'
Aupper
Buppercase
Ctoupper
Dlower
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like 'uppercase' or 'toupper'.
4fill in blank
hard

Fill both blanks to extract a substring from str starting at position 2 with length 4.

MATLAB
subStr = [1](str, [2], 5);
Drag options to blanks, or click blank then click option'
AextractBetween
BextractBefore
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong function names or incorrect start position.
5fill in blank
hard

Fill all three blanks to create a string array with words longer than 3 characters from the list.

MATLAB
filtered = words( [1](words) [2] [3] );
Drag options to blanks, or click blank then click option'
Astrlength
B>
C3
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using length instead of strlength, or Python-like list comprehension syntax.