Bird
0
0

Given two string arrays A = ['one'; 'two'] and B = ['red'; 'blue'], which MATLAB code concatenates corresponding rows, producing {'onered', 'twoblue'}?

hard📝 Application Q9 of 15
MATLAB - String Handling
Given two string arrays A = ['one'; 'two'] and B = ['red'; 'blue'], which MATLAB code concatenates corresponding rows, producing {'onered', 'twoblue'}?
AC = strcat(A, ' ', B);
BC = strcat(A + ' ' + B);
CC = strcat(cellstr(A), {' '}, cellstr(B));
DC = strcat(cellstr(A), ' ', cellstr(B));
Step-by-Step Solution
Solution:
  1. Step 1: Convert char arrays to cell arrays of strings

    cellstr converts rows of char arrays to cell strings.
  2. Step 2: Use strcat with cell arrays

    strcat(cellstr(A), ' ', cellstr(B)) concatenates each corresponding pair after trimming trailing spaces.
  3. Final Answer:

    C = strcat(cellstr(A), ' ', cellstr(B)); -> Option D
  4. Quick Check:

    Convert char arrays to cellstr before using strcat [OK]
Quick Trick: Use cellstr to convert char arrays before strcat [OK]
Common Mistakes:
  • Using + operator
  • Passing cell arrays incorrectly
  • Not converting char arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes