0
0
MATLABdata~10 mins

String vs character array in MATLAB - Interactive Practice

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.

MATLAB
str = [1]('Hello');
Drag options to blanks, or click blank then click option'
Astring
Bchar
Ccell
Darray
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'char' instead of 'string' creates a character array, not a string array.
2fill in blank
medium

Complete the code to create a character array.

MATLAB
charArray = [1]('Hello');
Drag options to blanks, or click blank then click option'
Acellstr
Bstring
Carrayfun
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' creates a string array, not a character array.
3fill in blank
hard

Fix the error in the code to concatenate two strings properly.

MATLAB
result = [1] + " World";
Drag options to blanks, or click blank then click option'
A'Hello'
B"Hello"
Cstring('Hello')
Dchar('Hello')
Attempts:
3 left
💡 Hint
Common Mistakes
Using character arrays with + causes an error.
4fill in blank
hard

Fill both blanks to create a character array and concatenate it with another.

MATLAB
a = [1]('Hi'); b = [2](' there'); result = [a b];
Drag options to blanks, or click blank then click option'
Achar
Bstring
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing string and character arrays causes errors or unexpected results.
5fill in blank
hard

Fill all three blanks to create a string array, convert it to character array, and get its length.

MATLAB
str = [1]({'cat', 'dog'}); charArr = [2](str(1)); len = [3](charArr);
Drag options to blanks, or click blank then click option'
Astring
Bchar
Clength
Dcellstr
Attempts:
3 left
💡 Hint
Common Mistakes
Using cellstr instead of string creates cell arrays, not string arrays.