Complete the code to create a string variable named greeting.
greeting = [1];In MATLAB, strings can be created using single quotes. So 'Hello, world!' is the correct way.
Complete the code to concatenate two strings str1 and str2.
result = [[1], str2];In MATLAB, square brackets concatenate strings or arrays. We want to concatenate str1 and str2, so use str1 inside the brackets.
Fix the error in the code to convert a string to uppercase.
upperStr = [1](inputStr);The MATLAB function to convert strings to uppercase is upper.
Fill both blanks to extract a substring from str starting at position 2 with length 4.
subStr = [1](str, [2], 5);
The function extractBetween extracts a substring from the start position to the end position (inclusive). Here, use start=2 and end=5 to get length 4.
Fill all three blanks to create a string array with words longer than 3 characters from the list.
filtered = words( [1](words) [2] [3] );
length instead of strlength, or Python-like list comprehension syntax.To filter, use logical indexing: words(strlength(words) > 3). So we use strlength, the operator >, and the number 3.