{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%plot gnuplot\n",
"%plot --format svg\n",
"t = linspace(0,6*pi,100);\n",
"plot(sin(t))\n",
"grid on\n",
"hold on\n",
"plot(cos(t), 'r')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"b = 10*cos(t)+30; plot(b); grid on\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x=0:0.1:10*pi;\n",
"y1=sin(x); y2=sqrt(x); y3=sin(x).*sqrt(x);\n",
"plot(x,y1,x,y2,x,y3);\n",
"legend('off');\n",
"grid('on');\n",
"axis([0 10 -1 3]);\n",
"axis('ij');"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x=linspace(0,30,200);\n",
"y1=sin(x)./exp(x/10); y2=1.5*sin(2*x)./exp(x/10);\n",
"plot(x,y1,x,y2);\n",
"xlabel('Duree [ms]');\n",
"ylabel('Amplitude [mm]');\n",
"title('Comparaison amortisseurs');\n",
"legend('amortisseur 1','amortisseur 2',4);\n",
"text(6,1,'Experience A', 'FontSize',14,'Rotation',-20,'Color','red');"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"subplot(2,2,1);\n",
"plot([0 1 1 0 0],[0 0 1 1 0]);\n",
"text(0.2,0.5,'Multiple plots');\n",
"axis('off'); legend('off'); title('zone 1');\n",
"subplot(2,2,2);\n",
"pie([2 1 5 3]); legend('a','b','c','d');\n",
"title('zone 2');\n",
"subplot(2,2,3);\n",
"bar(rand(18,1)); title('zone 3');\n",
"subplot(2,2,4);\n",
"fplot('x*cos(x)',[-10*pi 10*pi]);\n",
"title('zone 4');"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"warning: legend: 'best' not yet implemented for location specifier\r\n"
]
},
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"z1=0:0.1:10*pi;\n",
"x1=z1.*cos(z1);\n",
"y1=z1.*sin(z1);\n",
"x2=60*rand(1,20)-30; % 20 points de coord.\n",
"y2=60*rand(1,20)-30; % -30 < X,Y < 30\n",
"z2=35*rand(1,20); % 0 < Z < 35\n",
"#figure('Position',[startx,starty,200,200]);\n",
"plot3(x1,y1,z1,'r',x2,y2,z2,'o')\n",
"axis([-30 30 -30 30 0 35])\n",
"grid('on')\n",
"xlabel('x'); ylabel('y'); zlabel('z');\n",
"title('Graphique de type plot3')\n",
"legend('x=z*cos(z) y=z*sin(z)','semis aleatoire',1)\n",
"set(gca,'xtick',[-30:10:30])\n",
"set(gca,'ytick',[-30:10:30])\n",
"set(gca,'ztick',[0:5:35])\n",
"set(gca,'Xcolor',[0.5 0.5 0.5],'Ycolor',[0.5 0.5 0.5],\n",
" 'Zcolor',[0.5 0.5 0.5]);"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x=-2:0.2:2; y=x;\n",
"[X,Y]=meshgrid(x,y);\n",
"Z=100*sin(X).*sin(Y).*exp(-X.^2 + X.*Y - Y.^2);\n",
"meshc(X,Y,Z);\n",
"meshz(X,Y,Z);\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"min=-6; max=6; n_grid=30;\n",
"v_xyz = linspace(min,max,n_grid);\n",
"[Xm,Ym,Zm] = meshgrid(v_xyz, v_xyz, v_xyz);\n",
"V = sin( sqrt(Xm.^2 + Ym.^2 + Zm.^2) ) ./sqrt(Xm.^2 + Ym.^2 + Zm.^2);\n",
"slice(Xm,Ym,Zm, V,[],[],0)\n",
"hold('on')\n",
"slice(v_xyz,v_xyz,v_xyz,V,0,[0,4],[])\n",
"axis([min max min max min max])\n",
"colorbar"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"clf\n",
"[xi,yi]=meshgrid([-4:0.2:4]);\n",
"zi=5*exp(-xi.^2 + xi.*yi - yi.^2);\n",
"slice (v_xyz,v_xyz,v_xyz, V, xi,yi,zi)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x = -1:0.05:1;\n",
"y = x;\n",
"[xx, yy] = meshgrid(x,y);\n",
"zz = yy.^2 - xx.^2;\n",
"mesh(xx, yy, zz)\n",
"axis off"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Transfer function 'G' from input 'u1' to output ...\n",
"\n",
" s \n",
" y1: -----------\n",
" s^2 + s + 1\n",
"\n",
"Continuous-time model.\n"
]
}
],
"source": [
"pkg load control\n",
"%|R=L=C=1|:\n",
"R = 1; L = 1; C = 1;\n",
"G = tf([1/(R*C) 0],[1 1/(R*C) 1/(L*C)])"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"bode(G), grid"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"R1 = 5; G1 = tf([1/(R1*C) 0],[1 1/(R1*C) 1/(L*C)]);\n",
"R2 = 20; G2 = tf([1/(R2*C) 0],[1 1/(R2*C) 1/(L*C)]);\n",
"bode(G,'b',G1,'r',G2,'g'), grid\n",
"legend('R = 1','R = 5','R = 20')"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"warning: the 'timeoptions' function belongs to the control package from Octave\n",
"Forge but has not yet been implemented.\n",
"\n",
"Please read to learn how you can\n",
"contribute missing functionality.\n",
"warning: called from\n",
" __unimplemented__ at line 524 column 5\n",
"error: 'timeoptions' undefined near line 1 column 7\n",
"warning: lsim: arguments number 4 are invalid and are being ignored\n",
"warning: called from\n",
" lsim at line 89 column 5\n",
"warning: lsim: arguments number 4 are invalid and are being ignored\n",
"warning: called from\n",
" lsim at line 89 column 5\n",
"warning: lsim: arguments number 4 are invalid and are being ignored\n",
"warning: called from\n",
" lsim at line 89 column 5\n"
]
},
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"t = 0:0.05:250;\n",
"opt = timeoptions;\n",
"opt.Title.FontWeight = 'Bold';\n",
"subplot(311), lsim(G2,sin(t),t,opt), title('w = 1')\n",
"subplot(312), lsim(G2,sin(0.9*t),t,opt), title('w = 0.9')\n",
"subplot(313), lsim(G2,sin(1.1*t),t,opt), title('w = 1.1')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"warning: Octave provides lsode for solving differential equations. For more\n",
"information try 'help lsode'. Matlab-compatible ODE functions are\n",
"provided by the odepkg package. See\n",
".\n",
"\n",
"Please read to learn how you can\n",
"contribute missing functionality.\n",
"warning: called from\n",
" __unimplemented__ at line 524 column 5\n",
"error: 'odeset' undefined near line 1 column 10\n",
"error: 'odeopt' undefined near line 1 column 36\n",
"error: evaluating argument list element number 4\n"
]
}
],
"source": [
"omega = 1;\n",
"dy_dt = @(t,y) [y(2);\n",
"-omega.^2*sin(y(1))];\n",
"odeopt = odeset ('RelTol', 0.00001, 'AbsTol',0.00001,'InitialStep',0.5,'MaxStep',0.5);\n",
"[t,y] = ode45(dy_dt,[0 25], [0.0 1.0],odeopt);\n",
"\n",
"subplot(1,2,1);plot(t,y(:,1),'r-',t,y(:,2),'b-');xlabel('time'); legend('y1(t)','y2(t)');\n",
"\n",
"subplot(1,2,2);plot(y(:,1),y(:,2),'b-'); axis([-2.5 2.5 -2.5 2.5]); xlabel('y(2)');ylabel('y(1)');"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Octave",
"language": "octave",
"name": "octave"
},
"language_info": {
"file_extension": ".m",
"help_links": [
{
"text": "MetaKernel Magics",
"url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
}
],
"mimetype": "text/x-octave",
"name": "octave",
"version": "0.16.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}