Skip to content

Commit 969508e

Browse files
committed
Update to version 1.1.0
1 parent 533e47b commit 969508e

File tree

180 files changed

+1954
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+1954
-167
lines changed

.gitattributes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
*.mexa64 binary
66
*.mexw64 binary
77
*.mexmaci64 binary
8-
*.mlapp binary
8+
*.mlapp binary linguist-language=MATLAB
99
*.mldatx binary
1010
*.mlproj binary
11-
*.mlx binary merge=mlAutoMerge
11+
*.mlx binary merge=mlAutoMerge linguist-language=MATLAB
1212
*.p binary
1313
*.sfx binary
1414
*.sldd binary
1515
*.slreqx binary merge=mlAutoMerge
1616
*.slmx binary merge=mlAutoMerge
1717
*.sltx binary
1818
*.slxc binary
19-
*.slx binary merge=mlAutoMerge
19+
*.slx binary merge=mlAutoMerge linguist-language=Simulink
2020
*.slxp binary
2121

2222
## Other common binary file types

.gitignore

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
11
# List of untracked files to ignore
22

3+
# Autosave files
34
*/*.asv
45
*.asv
6+
*.m~
7+
*.autosave
8+
*.slx.r*
9+
*.mdl.r*
510

11+
# MATLAB Drive
12+
*.MATLABDriveTag
13+
14+
# Compiled files
15+
*.mex*
16+
*.p
17+
18+
# Compressed files
19+
*.zip
20+
21+
# Packaged app and toolbox files
22+
*.mlappinstall
23+
*.mltbx
24+
25+
# Deployable archives
26+
*.ctf
27+
28+
# Generated helpsearch folders
29+
helpsearch*/
30+
31+
# Defined Simulink cache folder
32+
Utilities/SimulinkCache/*
33+
34+
# Standard code generation folders
35+
slprj/
36+
sccprj/
37+
codegen/
38+
39+
# Code generation file
40+
*.eep
41+
*.elf
42+
*.hex
43+
*.bin
44+
45+
# Cache files
46+
*.slxc
47+
48+
# Project settings and other local data
49+
Utilities/ProjectSettings.mat
650
Data/allStorms.mat
751
Data/allStorms.csv
52+
Scripts/myLakeData.mat
53+
myLakeData.mat
54+
55+
# Test results
56+
SoftwareTests/TestResults_*
857

9-
Solutions.zip
58+
# GitLab page folder
59+
public/

.gitlab-ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
stages:
2+
# Set up two testing paths
3+
- setup
4+
- test
5+
- deploy
6+
- release
7+
8+
setup-job:
9+
tags:
10+
- matlab
11+
stage: setup
12+
script:
13+
- cd ..
14+
- if (test-path utilities) { rm -r -force utilities }
15+
- git clone [email protected]:modular-curriculum-content/utilities.git
16+
- cd $CI_PROJECT_NAME
17+
allow_failure: false
18+
19+
20+
smoke-test:
21+
# Smoke tests should run all the time
22+
tags:
23+
# Add additional tags like (e.g. - arduino) as required
24+
# Make sure that the runner you plan to use matches the tags
25+
- matlab
26+
stage: test
27+
script:
28+
- matlab -batch "openProject(pwd);RunAllTests(true)"
29+
when: always
30+
allow_failure: true
31+
artifacts:
32+
paths:
33+
- public/*
34+
expire_in: 1 years
35+
36+
pages:
37+
tags:
38+
- matlab
39+
stage: deploy
40+
script:
41+
- echo 'Deploying pages'
42+
artifacts:
43+
paths:
44+
- public
45+
46+
smoke-test-solution:
47+
tags:
48+
- matlab
49+
stage: release
50+
script:
51+
- matlab -batch "proj = openProject(pwd);
52+
addpath(genpath(proj.RootFolder));
53+
results = runtests(fullfile('InternalFiles','Tests','CI','SolnSmokeTests.m'));
54+
disp(table(results)); assertSuccess(results);"
55+
rules:
56+
# This test should always run when merging to main
57+
# And be available for manual running on any push
58+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
59+
when: always
60+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
61+
when: manual
62+
allow_failure: true
63+
64+
file-test:
65+
tags:
66+
- matlab
67+
stage: release
68+
script:
69+
- matlab -batch "proj = openProject(pwd);
70+
addpath(proj.RootFolder+'/InternalFiles/Tests/CI');
71+
results = runtests('OpenCloseFileTest.m');
72+
disp(table(results)); assertSuccess(results);"
73+
rules:
74+
# This test should always run when merging to main
75+
# And be available for manual running on any push
76+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
77+
when: always
78+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
79+
when: manual
80+
allow_failure: true
81+
82+
release-testing:
83+
tags:
84+
- matlab
85+
stage: release
86+
script:
87+
- matlab -batch "proj = openProject(pwd);
88+
cd ..;
89+
addpath(genpath(fullfile('utilities','TestingResources')));
90+
runCMTests"
91+
rules:
92+
# This test should always run when merging to main
93+
# And be available for manual running on any push
94+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
95+
when: always
96+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
97+
when: manual
98+
allow_failure: true

Data/.gitkeep

Whitespace-only changes.

Data/BakerLake.fig

14.9 MB
Binary file not shown.

Data/BakerLakeScale.fig

15.1 MB
Binary file not shown.

Data/lakeData.mat

0 Bytes
Binary file not shown.

Data/longLakeData.mat

1.38 KB
Binary file not shown.

Data/modernLakeData.mat

1.69 KB
Binary file not shown.

Data/testDrawing.mat

2.96 KB
Binary file not shown.

FunctionLibrary/.gitkeep

Whitespace-only changes.

FunctionLibrary/CollectData.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function [x,y] = CollectData()
2+
% figure('position',get(0,'screensize'))
3+
% figure("WindowState","maximized")
4+
figure
5+
axes('position',[0 0 1 1])
6+
grid on
7+
grid minor
8+
str = ["Select control points around your image by clicking and then double-click ", ...
9+
"to finish data collection. Close the figure window to return to the script."];
10+
annotation("textbox",[.05 .9 .1 .1],"String",str,"FitBoxToText","on")
11+
ax = gca;
12+
roi = drawpolygon(ax);
13+
x = roi.Position(:,1);
14+
y = roi.Position(:,2);
15+
end

FunctionLibrary/IdentifyLakeShape.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function roi = IdentifyLakeShape
2+
fig = uifigure("Name","Trace the outline of the lake");
3+
gx = geoaxes("Parent",fig);
4+
geoplot(gx,48.7,-121.658)
5+
geolimits(gx,[48.63,48.75],[-121.665 -121.65])
6+
geobasemap(gx,'satellite')
7+
roi = drawpolygon(gx);
8+
end

FunctionLibrary/LoadStormData.mlx

9.5 KB
Binary file not shown.

FunctionLibrary/MeasureGeoScale.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function longScale = MeasureGeoScale
2+
fig = uifigure("Name","Measure 2 km");
3+
gx = geoaxes("Parent",fig);
4+
geoplot(gx,48.7,-121.658)
5+
geolimits(gx,[48.63,48.75],[-121.665 -121.65])
6+
geobasemap(gx,'satellite')
7+
roi = drawpolygon(gx);
8+
longVals = roi.Position(:,2);
9+
10+
longScale = 2/(longVals(2)-longVals(1));
11+
12+
end

FunctionLibrary/cnPDE.m

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
function u = cnPDE(f,alpha,beta,tEnd,dx,gamma,L)
2+
% Solve the 1D heat equation u_t = gamma*u_{xx} on a rod of length L
3+
% using the Crank-Nicolson method
4+
% u(t,0) = alpha(t)
5+
% u(t,L) = beta(t)
6+
% u(0,x) = f(x)
7+
% The desired spatial resolution is dx
8+
% Output is u = u(tEnd,x_m), a vector of values on the mesh points
9+
10+
% %% Define dt with reference to both error and stability concerns
11+
% Optimal step size dtOpt for stability
12+
dtOpt = nan;
13+
14+
% Forcing an integer numbers of dt steps that terminate at tEnd
15+
dt = tEnd/ceil(tEnd/dtOpt);
16+
17+
% %% Set up helper values for defining the required matrices A and B
18+
% %% such as the number of rows, the value of mu, etc
19+
20+
21+
% %% Define modA for the explicit updating rule
22+
% %% modA-I = (A-I)/2, where I is the identity matrix
23+
24+
25+
% %% Define modB for the implicit updating rule
26+
% %% modB-I = (B-I)/2, where I is the identity matrix
27+
28+
29+
% %% Initialize bAvg = b^(j)+b^(j+1) as a vector of zeros
30+
31+
32+
% %% Define a spatial mesh vector xVals
33+
xVals = [0;0;0];
34+
35+
% %% Set up a column vector u0 of the initial values of u when t=0
36+
u0 = 0;
37+
u = u0;
38+
39+
% %% Initialize the output to the interior points of u0
40+
41+
42+
% To visualize the outputs
43+
p = plot(xVals,u0,"LineWidth",4);
44+
ax = p.Parent;
45+
46+
% Set the y limits to reasonable fixed values
47+
minAlpha = min(alpha(0:dt:tEnd));
48+
maxAlpha = max(alpha(0:dt:tEnd));
49+
minBeta = min(beta(0:dt:tEnd));
50+
maxBeta = max(beta(0:dt:tEnd));
51+
yLower = min([ax.YLim(1),minAlpha,minBeta]);
52+
yUpper = max([ax.YLim(2),maxAlpha,maxBeta]);
53+
scale = (yUpper-yLower)*0.05;
54+
ax.YLim = [yLower-scale yUpper+scale];
55+
56+
% These values generate well-sized y limits for the example function
57+
% used in partialDiffEqs.mlx
58+
ylim([-4 1.5]);
59+
title("Solving $\frac{\partial u}{\partial t} = \gamma \frac{\partial^2 u}{\partial x^2}$","Interpreter","latex")
60+
subtitle("$t=0$","Interpreter","latex")
61+
xlabel("$x$","Interpreter","latex")
62+
ylabel("$u$","Interpreter","latex")
63+
64+
% %% Compute new values for halfB*u^(j+1)-b^(j+1) = halfA*u^(j)+b^(j)
65+
% %% Loop over timesteps to reach tEnd
66+
for j = 1:(tEnd/dt)
67+
68+
69+
% To visualize the outputs
70+
hold on
71+
delete(ax.Children(1:end-1));
72+
plot(xVals,[alpha(j*dt);u;beta(j*dt)],"k","LineWidth",1)
73+
subtitle("$t = $"+dt*j)
74+
drawnow
75+
pause(0.1)
76+
hold off
77+
% End visualization code
78+
end
79+
80+
end

FunctionLibrary/eulerMethod.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function [xApprox,yApprox]=eulerMethod(f,init,n,h)
2+
arguments
3+
f function_handle % integrand, e.g. @(x) x.^2
4+
init (1,2) double % initial value (x0,y0)
5+
n (1,1) double {mustBePositive,mustBeInteger} % number of steps
6+
h (1,1) double % step size
7+
end
8+
9+
% The function returns two length (n+1) vectors of
10+
% estimated x and y values
11+
12+
% Initialize the output with the initial value
13+
% Initialize the output with the initial value
14+
xApprox = nan(n+1,1);
15+
yApprox = nan(n+1,1);
16+
xApprox(1) = init(1);
17+
yApprox(1) = init(2);
18+
19+
% Fill in the details of the implementation here
20+
21+
end

FunctionLibrary/eulerMethodDE.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function [xApprox,yApprox]=eulerMethodDE(f,init,n,h)
2+
arguments
3+
f function_handle % derivative dy/dt = f(t,y)
4+
init (1,2) double % initial value [t0 y0]
5+
n (1,1) double {mustBePositive,mustBeInteger} % number of steps
6+
h (1,1) double % step size
7+
end
8+
% f is a function handle, e.g. @(t,y) t.^2.*cos(y)
9+
10+
% The function returns two length (n+1) vectors of
11+
% estimated x and y values
12+
13+
% Initialize the output with the initial value
14+
% Initialize the output with the initial value
15+
xApprox = nan(n+1,1);
16+
yApprox = nan(n+1,1);
17+
xApprox(1) = init(1);
18+
yApprox(1) = init(2);
19+
20+
% Fill in the details of the implementation here
21+
22+
23+
end

0 commit comments

Comments
 (0)