I wrote down the differential equations for a two-mass oscillator, transformed it to state form and solved the model with scilab, which worked perfectly (see picture in the appendix). Now, I want to generate a plot for the amplitudes and phase frequency response of this system, but I don't know how to to this in scilab. Can anyone help me out here?
The scilab-code is as follows:
m1 = 0.01; m2 = 0.005; C1 = 200; C2 = 100; D1 = 0.0; D2 = 0.0; Fdach = 0.1; omega = sqrt(C1/m1); function f=rechteSeite(t, y) A = [[0,0,1,0];[0,0,0,1];[-(C1+C2)/m1,C2/m1,-(D1+D2)/m1,D2/m1];C2/m2,-C2/m2,D2/m2,-D2/m2]; q = [0;0;1/m1;0]*(Fdach)*cos(omega*t); f = A*y+q; endfunction t = linspace(0,20,10000); y0 = [0,0,0,0]'; t0 = 0; y = ode(y0,t0,t,rechteSeite); subplot(311) plot(t,y(1,:));//,t,y(2,:));//,t,y(3,:),t,y(4,:)); hl=legend(['x1';'x2';'x1p';'x2p']); subplot(312) plot(t,y(2,:));//,t,y(2,:));//,t,y(3,:),t,y(4,:)); hl=legend(['x2';'x2';'x1p';'x2p']);
See also the uploaded picture for further information.
M = [m1,0;0,m2];
K = [C1+C2,-C2;-C2,C2];
D = [D1+D2,-D2;-D2,D2];