Skip to content

Commit

Permalink
finish matlab layout episode
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-wild committed Oct 15, 2024
1 parent 0c14c23 commit f273740
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 51 deletions.
81 changes: 31 additions & 50 deletions episodes/matlab-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,81 +47,62 @@ 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?
```
13 * 8
```
:::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 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
::::::::::::::::::::::::::::::::::::::::::::::::

2 changes: 1 addition & 1 deletion episodes/what-is-matlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f273740

Please sign in to comment.