How to write a loop that spells the word “aluminum,” adding one letter at a time?

 Accepted Answer

>> S = 'aluminium';
>> for k = 1:numel(S), disp(S(1:k)), end
a
al
alu
alum
alumi
alumin
alumini
aluminiu
aluminium
If you actually want to learn how to write your own MATLAB code and not just get other people to do your homework for you, then you should do these tutorials:

More Answers (0)

Community Treasure Hunt

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

Start Hunting!