concept-collection / numbl-embed-example
numbl-embed-example / example1.md
48 lines · 1.1 KBCodeBlameHistory
f9f9749initialJeremy Magland 1<script src="https://numbl.org/numbl-embed.js"></script>
3This demonstrates how to embed numbl in a markdown file that can be rendered on GitHub Pages.
5<numbl-embed>
6<iframe width="100%" height="600" frameborder="0"></iframe>
7<script type="text/plain" class="matlab-script">
8% Matrix operations example
9A = [8, 1, 6; 3, 5, 7; 4, 9, 2];
10disp('Matrix A:')
11disp(A)
13disp('Sum of each row:')
14disp(sum(A, 2))
16disp('Sum of each column:')
17disp(sum(A, 1))
19disp('Sum of diagonal:')
20disp(sum(diag(A)))
22disp('Total sum:')
23disp(sum(sum(A)))
24</script>
25</numbl-embed>
27If it worked, you should see an embedded numbl above with a matrix operations example.
4511dd9updatesJeremy Magland 29Here's a plotting example:
f9f9749initialJeremy Magland 30
31<numbl-embed>
32<iframe width="100%" height="600" frameborder="0"></iframe>
33<script type="text/plain" class="matlab-script">
9aae1b2update exampleJeremy Magland 34% Damped oscillation
35t = linspace(0, 10, 200);
36y = exp(-0.3 * t) .* sin(2 * pi * t);
37plot(t, y)
38title('Damped Oscillation')
39xlabel('Time')
40ylabel('Amplitude')
f9f9749initialJeremy Magland 41</script>
42</numbl-embed>
cbc4e2ainteractive replJeremy Magland 43
44Here's an interactive REPL where you can type and run commands:
46<numbl-embed mode="repl">
47<iframe width="100%" height="500" frameborder="0"></iframe>
48</numbl-embed>