How can I make a method that takes a String and prints it out in AltCase meaning that the first letter is uppercase and each subsequent character alternates between lowercase and uppercase.

Answers (2)

>> str = 'hello world!';
>> str(1:2:end) = upper(str(1:2:end));
>> str(2:2:end) = lower(str(2:2:end))
str = HeLlO WoRlD!
First you have to show us your String class. MATLAB does not have a String class.
It looks to me that you are asking homework questions about a different programming language.

Tags

Asked:

on 2 Dec 2015

Answered:

on 2 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!