File: octave_sample.mdw

package info (click to toggle)
python-pweave 0.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,064 kB
  • sloc: python: 30,281; makefile: 167
file content (57 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

# Using Octave with Pweave

You can also use Pweave to publish reports using GNU Octave or Matlab. The
was  released with Pweave 0.23.

**Features:**

* Inline code and noweb style chunks
* Capturing of figures

**Limitations**

* No terminal chunks
* Only one figure/chunk

You can use inline code chunks like in Python documents:

Give y value 300 <%y=300;%> in hidden chunk.

And let's verify that it worked:

<<>>=
y
@

You can also display the result from inline chunk 2+5=<%=2+5%>

## Solving least squares


and trying out plotting features:

<<fig=True>>=
x = (0:25) + randn(1, 26);
y = linspace(0, 5, length(x));
a = x' \ y'
plot(x , y, 'o')
hold on
plot(x, a*x, 'r')
hold off
figure()
hist(a*x - y)
title('Histogram of residuals')
@

And include a plot but hide the code:

<<fig=True, echo=False, caption="Sinc function">>=
x = linspace(0, 4*pi, 200);
plot(x, sinc(x), 'linewidth', 1)
hold on
plot(x, sinc(0.7*x), 'g', 'linewidth', 1)
hold off
xlabel('x')
ylabel('sinc(x)')
@