Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
Created May 26, 2013 13:00
Show Gist options
  • Save mzdravkov/5652713 to your computer and use it in GitHub Desktop.
Save mzdravkov/5652713 to your computer and use it in GitHub Desktop.
Octave tasks from classwork.
p = [1 -3 2];
r = roots(p);
x = linspace(-1, 3);
plot(x, polyval(p, x));
hold on;
plot(r, zeros(size(r)), "marker", "x", "markersize", 21, "color", "red", "linestyle", "none")
hold on;
plot(x, zeros(size(x)), '.', 'color', 'red');
x = y = linspace(-360, 360, 26);
[xx, yy] = meshgrid (x, y);
z = sin(xx .* yy);
surf(xx, yy, z);
%# x = y = linspace(-360, 360, 10)
%# x = y = 0.2:10;
x = y = linspace(0.2, 10, 100);
r = sqrt(x .^ 2 + y .^ 2);
[xx, yy] = meshgrid(x, y);
%# u = 1/(r .^ 12) - 1/(r .^ 6);
%# surf(xx, yy, u);
u = 1 ./ (r .^ 12) - 1 ./ (r .^ 6);
plot(r, u);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment