swcarpentry / matlab-novice-inflammation

Programming with MATLAB
http://swcarpentry.github.io/matlab-novice-inflammation/
Other
32 stars 67 forks source link

Include vectorization #19

Open shwina opened 9 years ago

shwina commented 9 years ago

In a discussion with Ken Deeley and Jos Martin from Mathworks, and @gvwilson, the following improvements to the SWC MATLAB material have been suggested:

  1. MATLAB environment - the lessons don't have, for instance, screenshots of the MATLAB environment. While this reduces maintenance costs, it might also make learning more difficult for beginners. Greg's suggestion: short GIFs/videos of the MATLAB environment
  2. Vectorization - effective use of MATLAB entails familiarity with the idea of vectorization. We should introduce this in some depth in our lesson.
IsaKiko commented 9 years ago

Where do you thing vectorization should go? Before or after loops? Are we including logical indexing? I'm hoping this is not too confusing since we're already teaching loops.

gvwilson commented 9 years ago

The MATLAB folks think vectorization should come first, and loops later

shwina commented 9 years ago

I think it's worth having learners use both approaches to accomplish the same task, have them understand why vectorization is generally a better idea, and also when it becomes necessary to use a for loop. The challenge will be making sure all of this doesn't stick out awkwardly in the lessons :)

gcapes commented 3 years ago

We now have a screenshot of MATLAB, and a gif of debugging. I'll have a think about how to cover vectorisation

gcapes commented 3 years ago

Some thoughts: The arrays episode (2) is quite short, so could probably accommodate some examples of whole-array operations, assignment to a slice, and logical indexing which is important in vectorization.

In ep5 (loops) some of the examples would be much better achieved using whole-array operations e.g. printing each letter in a word, summing all the elements of an array etc. So while they're poorly-motivated examples of loops, they are easy to follow examples, and give a natural motivation for vectorization. We could show how some of these examples could be achieved using vectorization, and come up with an example which doesn't vectorize before looping over files (which also doesn't vectorize).

cjfullerton commented 2 years ago

I'm interested in having a crack at adding some vectorization material to the lessons as I think it's an important part of using MATLAB.

@gcapes - these are great suggestions. I think it's sensible to introduce vectorization in the arrays lesson, but although the lesson is short the array indexing material is conceptually dense. I'll add some material and we can see how it looks.

gcapes commented 2 years ago

Would be good to see your ideas. Perhaps it might be useful to refer back to mean i.e. an inbuilt vectorised function which is previously used in the lesson