Bird
0
0

Given a string with mixed case letters, how can you count the number of uppercase letters in MATLAB?

hard📝 Application Q9 of 15
MATLAB - String Handling
Given a string with mixed case letters, how can you count the number of uppercase letters in MATLAB?
AUse strcat() to join uppercase letters
BUse lower() and count characters
CUse isstrprop() with 'upper' and sum the result
DUse length() directly on the string
Step-by-Step Solution
Solution:
  1. Step 1: Identify function to test character properties

    isstrprop() checks character types, including uppercase letters.
  2. Step 2: Apply isstrprop() with 'upper' and sum

    This returns a logical array; summing counts how many are true (uppercase).
  3. Final Answer:

    Use isstrprop() with 'upper' and sum the result -> Option C
  4. Quick Check:

    Count uppercase = sum(isstrprop(str,'upper')) [OK]
Quick Trick: Use isstrprop() to test character types [OK]
Common Mistakes:
  • Using lower() instead of isstrprop()
  • Trying to join letters with strcat()
  • Using length() without filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes