octavemagic_extension.ipynb
272 lines
| 145.2 KiB
| text/plain
|
TextLexer
InĀ [9]:
%load_ext octavemagic
InĀ [10]:
x = %octave [1 2; 3 4];
x
Out[10]:
InĀ [11]:
a = [1, 2, 3]
%octave_push a
%octave a = a * 2;
%octave_pull a
a
Out[11]:
InĀ [12]:
%%octave -i x -o y
y = x + 3;
InĀ [13]:
y
Out[13]:
InĀ [14]:
%%octave -f svg
p = [12 -2.5 -8 -0.1 8];
x = 0:0.01:1;
polyout(p, 'x')
plot(x, polyval(p, x));
InĀ [15]:
%%octave -s 500,500
# butterworth filter, order 2, cutoff pi/2 radians
b = [0.292893218813452 0.585786437626905 0.292893218813452];
a = [1 0 0.171572875253810];
freqz(b, a, 32);
InĀ [16]:
%%octave -s 600,200 -f png
subplot(121);
[x, y] = meshgrid(0:0.1:3);
r = sin(x - 0.5).^2 + cos(y - 0.5).^2;
surf(x, y, r);
subplot(122);
sombrero()
InĀ [16]: