diff --git a/02-arrays.md b/02-arrays.md index 7e967486..863d06d1 100644 --- a/02-arrays.md +++ b/02-arrays.md @@ -217,7 +217,7 @@ last three characters: gen 'gen' element(1:2:end) % Select every other element starting at first ans = - 'oye + 'oye' element(2:end-1) % Select elements starting with 2nd, until last-but-one ans = 'xyge' diff --git a/03-plotting.md b/03-plotting.md index 4b7f20b2..a041eaf9 100644 --- a/03-plotting.md +++ b/03-plotting.md @@ -373,7 +373,7 @@ Hint: search the documentation for *standard deviation* :::::::::::::::::::::::::::::::::::::::::::::::::: It is often convenient to combine multiple plots into one figure -using the `subplot`command which plots our graphs in a grid pattern. +using the `subplot` command which plots our graphs in a grid pattern. The first two parameters describe the grid we want to use, while the third parameter indicates the placement on the grid. diff --git a/04-scripts.md b/04-scripts.md index d9a46c35..53f11e81 100644 --- a/04-scripts.md +++ b/04-scripts.md @@ -33,7 +33,7 @@ is just a text file with a `.m` extension. We've written commands to load data from a `.csv` file and display some plots of statistics about that data. Let's put those commands in a script called `plot_patient1.m`, -which we'll save in our current directory,`matlab-novice-inflammation`. +which we'll save in our current directory, `matlab-novice-inflammation`. To create a new script in the current directory, we use diff --git a/05-loops.md b/05-loops.md index 6453060b..b873a311 100644 --- a/05-loops.md +++ b/05-loops.md @@ -329,7 +329,7 @@ aluminum ```matlab % spell a string adding one letter at a time using a loop -word = 'aluminium'; +word = 'aluminum'; for letter = 1:length(word) disp(word(1:letter)) @@ -386,7 +386,7 @@ a ```matlab % Spell a string in reverse using a loop -word = 'aluminium'; +word = 'aluminum'; for letter = length(word):-1:1 disp(word(letter)) diff --git a/06-cond.md b/06-cond.md index 687635d5..8c4cc2b0 100644 --- a/06-cond.md +++ b/06-cond.md @@ -277,7 +277,7 @@ disp(['sum of negative values: ', num2str(neg_total)]) ``` ```output -sum of positive values: 26 +sum of positive values: 20 sum of negative values: -6 ``` @@ -378,7 +378,7 @@ for i = 1:length(files) img_name = replace(file_name, '.csv', '.png'); % Generate path to data file and image file - file_name = fullfile('data', filename); + file_name = fullfile('data', file_name); img_name = fullfile('results', img_name); patient_data = readmatrix(file_name); diff --git a/08-defensive.md b/08-defensive.md index 525a7763..bc14c002 100644 --- a/08-defensive.md +++ b/08-defensive.md @@ -133,7 +133,7 @@ The three preconditions catch invalid inputs: ``` ```error -Error using normalize_rectangle (line 6) +Error using normalize_rectangle (line 7) Rectangle must contain 4 coordinates ``` @@ -177,7 +177,7 @@ the assertion is triggered: error: Calculated upper X coordinate invalid ``` -Re-reading our function, we realize that line 19 should +Re-reading our function, we realize that line 21 should divide `dy` by `dx`. If we had left out the assertion at the end of the function, we would have created and returned something that had the right shape as @@ -294,7 +294,7 @@ test_range_overlap ```error Undefined function or variable 'range_overlap'. -Error in test_range_overlap (line 6) +Error in test_range_overlap (line 5) assert(isequal(range_overlap([0, 1.0]),[0, 1.0])) ``` @@ -321,6 +321,7 @@ function varlist(varargin) fprintf('Number of arguments: %d\n',nargin) celldisp(varargin) +end ``` ```matlab @@ -378,6 +379,7 @@ function overlap = range_overlap(________) end overlap = [lowest, highest]; +end ``` ::::::::::::::: solution @@ -402,6 +404,7 @@ function overlap = range_overlap(varargin) end overlap = [lowest, highest]; +end ``` ::::::::::::::::::::::::: @@ -462,12 +465,13 @@ function overlap = range_overlap(varargin) % Catch non-overlapping ranges if low >= highest || high<=lowest - output_range = NaN; + overlap = NaN; return end end overlap = [lowest, highest]; +end ``` ::::::::::::::::::::::::: diff --git a/md5sum.txt b/md5sum.txt index 2ef8f06f..e792a8f3 100644 --- a/md5sum.txt +++ b/md5sum.txt @@ -4,13 +4,13 @@ "config.yaml" "ab22e2bf5a5cd3a2bd65498a7ca6a898" "site/built/config.yaml" "2023-04-26" "index.md" "8f1498ab2efb0d63a9b7a95bf33510dd" "site/built/index.md" "2023-04-26" "episodes/01-intro.md" "1d2ac5ffc776e9e9eaf062e8dbf015fa" "site/built/01-intro.md" "2023-04-26" -"episodes/02-arrays.md" "d6242c23a3d07c947f9cfc0111c0e4ac" "site/built/02-arrays.md" "2023-04-26" -"episodes/03-plotting.md" "438d2a773392adfd2fde63e178f4fb83" "site/built/03-plotting.md" "2023-04-26" -"episodes/04-scripts.md" "d928cc345f515680e04f9d25cc2f2cec" "site/built/04-scripts.md" "2023-04-26" -"episodes/05-loops.md" "88c1b90d65bbeb46692922b805d4a251" "site/built/05-loops.md" "2023-04-26" -"episodes/06-cond.md" "f276db74c3dfdc7bfe19475d917d227d" "site/built/06-cond.md" "2023-04-26" +"episodes/02-arrays.md" "358c92e1971b0415b511b49db391b72f" "site/built/02-arrays.md" "2025-01-08" +"episodes/03-plotting.md" "19546dbd8aa19d7ba37177b0cbe05430" "site/built/03-plotting.md" "2025-01-08" +"episodes/04-scripts.md" "aa8e01310829456ef15a2e100c181f68" "site/built/04-scripts.md" "2025-01-08" +"episodes/05-loops.md" "1b07298cd425a9f14a44c34a4881d3ab" "site/built/05-loops.md" "2025-01-08" +"episodes/06-cond.md" "b6dcd573cfdac601fbc798d31e2395c6" "site/built/06-cond.md" "2025-01-08" "episodes/07-func.md" "d97fe1f1091b1c4a49c9bcb39a4d0b57" "site/built/07-func.md" "2025-01-07" -"episodes/08-defensive.md" "0f8afd21566dcf43343fa09af7590f6a" "site/built/08-defensive.md" "2023-04-26" +"episodes/08-defensive.md" "42008b6a807d20022eb6fcde361473ba" "site/built/08-defensive.md" "2025-01-08" "instructors/instructor-notes.md" "65e75f30364d641c7728dae2adbd85d2" "site/built/instructor-notes.md" "2023-04-26" "learners/discuss.md" "e7d00cb8aa5e7de1aaaa659777dad8d4" "site/built/discuss.md" "2023-04-26" "learners/reference.md" "c7f26691fa869c23d957a9f7b3bf9796" "site/built/reference.md" "2023-04-26"