1 Introduction
This is the introduction to the Matlab programming, including how to use variable and various matrix operations.
2 Procedures
-
Why do we clear the command window and workspace at the beginning of a script?
To ensure the result from last session does not interference with the result of current script.
-
Why would we use variables instead of just using the numbers, which is called hard-coding?
Using variables makes modifying the script much easier and consistent, especially when a variable has been referenced multiple times.
-
Think about what system would you personally use to organize your variables and remember what each means? Give a few examples with explanations of what they mean.
I use two characters like
xa
to denote scalar variables,aa
for array variables. The result of computations are named by 3-4 character names, such assum
,diff
(for difference). -
What are the benefits to using the array indexing approach?
This helps editing a small fragment of data from a larger data set.
-
In your opinion, would the automatically generated variable ans or a user-defined variable be more useful in writing scripts?
User-defined variables are more suitable for non-interactive sessions.
3 Conclusion
I have not used Matlab before, but I have used APL (which is also an array oriented program language with fun character set). In my opinion Matlab is a hybrid of Python and APL, but I can see it is probably also influenced by LaTeX.
I used the online version of Matlab for this assignment, but it is not intuitive to find where to download the file from the web interface. At the end I figured it can be downloaded at user account page from MathWorks.
Some Matlab expressions shown in the instructions, such as
[1:10]
, or mb * inv(ma)
would be prompted
as boilerplate or inefficient. It would be good to fix them or
indicate the better methods.