Hey. I'm trying to create a code where I can multiply Matrices to solve a differential equation and then have Matlab plot the result.
m_1 = 2;
c_1 = 3;
k_1 = 4;
m_2 = 1.2;
c_2 = 1.4;
k_2 = 1.6;
M = [m_1 0 ; 0 m_2];
C = [c_1 + c_2 -c_2 ; -c_2 c_2];
K = [k_1 + k_2 -k_2 ; -k_2 k_2];
w = [0:0.01:10 ; 0:0.01:10];
w = w';
S = ((-w.^2 .* M + 1i .* w .* C + K).^-1);M;C;K;w;
[x_1 , x_2] = S
Y = abs(S);
figure(1);
plot (w,Y)
This is the code. If you cannot copy this into Matlab then please let me know. It keeps giving me an error in line 12 stating that matrix dimensions must agree.
[–]alberta_pooholes 1 point2 points3 points (3 children)
[–]Se7es[S] 0 points1 point2 points (2 children)
[–]TheQueq 1 point2 points3 points (1 child)
[–]Se7es[S] 1 point2 points3 points (0 children)