From f27374027a4f0a44025e68987b8c343c38cf34cf Mon Sep 17 00:00:00 2001 From: Chris Wild Date: Tue, 15 Oct 2024 11:16:04 +0100 Subject: [PATCH] finish matlab layout episode --- episodes/matlab-layout.md | 81 +++++++++++++++----------------------- episodes/what-is-matlab.md | 2 +- 2 files changed, 32 insertions(+), 51 deletions(-) diff --git a/episodes/matlab-layout.md b/episodes/matlab-layout.md index 5f4611f..202a3b9 100644 --- a/episodes/matlab-layout.md +++ b/episodes/matlab-layout.md @@ -47,13 +47,19 @@ If any of this isn't clear again don't worry! This course will further explore a ## Editor VS Command Window -You can write and run MATLAB code in both the command window and the editor so understanding the purpose and differences of them is important. +You can write and run MATLAB code in both the command window and the editor so understanding the purpose and differences of them is important. + +| Command Window | Editor | +|---|---| +| Quick calculations | Creating and editing persistent scripts | +| Testing | Reading and using others code | +| Interactive exploration | Creating functions | +| Debugging | | -### Command Window -Starting with the command window, here you write a single line of MATLAB code, hit enter and MATLAB will run the code! ::: challenge +### Challenge 1: Using the command window What is the output of this command? ``` @@ -61,67 +67,42 @@ What is the output of this command? ``` ::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor - -Inline instructor notes can help inform instructors of timing challenges -associated with the lessons. They appear in the "Instructor View" +::: instructor -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +May be worth explaining that '*' is used for multiplication in many programming languages and '/' for divide -::::::::::::::::::::::::::::::::::::: challenge +::: -## Challenge 1: Can you do it? +::: challenge +### Challenge 2: Using the editor -What is the output of this command? +Press 'New' at the top left and type the following into your editor. Then press 'Run' in the EDITOR tab at the top. -```r -paste("This", "new", "lesson", "looks", "good") ``` - -:::::::::::::::::::::::: solution - -## Output - -```output -[1] "This new lesson looks good" +b = 136 / 8 ``` -::::::::::::::::::::::::::::::::: - - -## Challenge 2: how do you nest solutions within challenge blocks? - -:::::::::::::::::::::::: solution - -You can add a line with at least three colons and a `solution` tag. +1. What do you have to do in order for the code to run? +2. What is the output? -::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::: - -## Figures - -You can use pandoc markdown for static figures with the following syntax: +::: solution -`![optional caption that appears below the figure](figure url){alt='alt text for -accessibility purposes'}` +1. The editor modifies and runs a MATLAB file (m-file), so in order to run what is in the editor you will be required to create and save a file. -![You belong in The Carpentries!](https://raw.githubusercontent.com/carpentries/logo/master/Badge_Carpentries.svg){alt='Blue Carpentries hex person logo with no text.'} - -## Math - -One of our episodes contains $\LaTeX$ equations when describing how to create -dynamic reports with {knitr}, so we now use mathjax to describe this: +2. 17 +::: +::: +As you saw in the challenge above, using the command window requires you to create and save a file with the extension `.m`. This means that when you next come to do your analysis, processing, etc. you can reopen this file and work from it again. -`$\alpha = \dfrac{1}{(1 - \beta)^2}$` becomes: $\alpha = \dfrac{1}{(1 - \beta)^2}$ +::: callout +### Saving your work -Cool, right? +Unlike the editor, any work done in the command window is not saved! This means that if you close MATLAB or your computer this work will be lost. Hence why you should use it only for quick temporary tasks +::: ::::::::::::::::::::::::::::::::::::: keypoints - -- Use `.md` files for episodes when you want static content -- Use `.Rmd` files for episodes when you need to generate output -- Run `sandpaper::check_lesson()` to identify any issues with your lesson -- Run `sandpaper::build_lesson()` to preview your lesson locally - +- The MATLAB interface is very customisable, adjust it to suit you +- Use the command window for quick tasks like exploring data, testing, etc. +- Use the editor for developing code you want to persist between sessions :::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/what-is-matlab.md b/episodes/what-is-matlab.md index 7499902..2d324d4 100644 --- a/episodes/what-is-matlab.md +++ b/episodes/what-is-matlab.md @@ -16,7 +16,7 @@ exercises: 2 - Explain what tasks MATLAB is well suited for - Explain how MATLAB compares to other common tools (Python, R) -- Understand the tradeoffs of choosing MATLAB as a tool +- Understand the trade-offs of choosing MATLAB as a tool ::: ## Introduction