swcarpentry / matlab-novice-inflammation

Programming with MATLAB

Home Page:http://swcarpentry.github.io/matlab-novice-inflammation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ep 5: poorly motivated example

gcapes opened this issue · comments

This is the second example of a loop which is given.

LOOP_DEMO   Demo script to explain loops

len = 0
for vowel = 'aeiou'
    len = len + 1;
end

disp(['Number of vowels: ', num2str(len)])

It's not very realistic because you'd be better just using the length() function.

A better example might be to calculate a series like the fibonacci which isn't easy to vectorise

Note that the debugging gif will need re-doing if this example is changed.

Fixed in #232