Open shwina opened 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.
The MATLAB folks think vectorization should come first, and loops later
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 :)
We now have a screenshot of MATLAB, and a gif of debugging. I'll have a think about how to cover vectorisation
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).
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.
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
In a discussion with Ken Deeley and Jos Martin from Mathworks, and @gvwilson, the following improvements to the SWC MATLAB material have been suggested: