From: Nils Forssén Date: Fri, 9 Dec 2022 19:03:22 +0000 (+0100) Subject: pushing X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=e4e6703900c51cd5ce8cef6dcc7f33262b3c4492;p=TMME12.git pushing --- diff --git a/brick_ekv.m b/brick_ekv.m index 713a49e..86e8318 100644 --- a/brick_ekv.m +++ b/brick_ekv.m @@ -3,4 +3,5 @@ z = y(1); z_dot = y(2); y_dot = zeros(2,1); y_dot(1) = z_dot; -y_dot(2) = -g; \ No newline at end of file +y_dot(2) = -g; +end \ No newline at end of file diff --git a/collar_ekv.m b/collar_ekv.m index cd7dc0b..d3612a3 100644 --- a/collar_ekv.m +++ b/collar_ekv.m @@ -4,4 +4,5 @@ z_dot = y(2); y_dot = zeros(2,1); y_dot(1) = z_dot; -y_dot(2) = -g - ((k/m)*z*(1-((3*b)/(2*sqrt((z.^2) + (b.^2)))))); \ No newline at end of file +y_dot(2) = -g - ((k/m)*z*(1-((3*b)/(2*sqrt((z.^2) + (b.^2)))))); +end \ No newline at end of file diff --git a/mek_upg.asv b/mek_upg.asv deleted file mode 100644 index 17fec0d..0000000 --- a/mek_upg.asv +++ /dev/null @@ -1,90 +0,0 @@ -%% init -clear -clc - -set(gcf, 'Position', [50 50 1200 900]); - -stopheight=0; -g = 9.82; -k = 100; -m = 0.5; -b = 0.3; - -t_max = 10; -z_0 = sqrt(3)*b; - -hold on; - -%% calcs -options_collar = odeset("Events", @(t,y) collar_events(t, y, stopheight), ... - 'RelTol', 1e-3,'AbsTol', 1e-6, 'MaxStep', 0.01); - -[t_vek_collar,Y_collar]=ode45(@(t,y) collar_ekv(t,y,g,k,m,b), [0 t_max], [z_0 0], options_collar); - -options_brick = odeset("Events", @(t,y) brick_events(t, y, stopheight), ... - 'RelTol', 1e-3,'AbsTol', 1e-6, 'MaxStep', 0.01); - -[t_vek_brick,Y_brick]=ode45(@(t,y) brick_ekv(t,y,g), [0 t_max], [z_0 0], options_brick); - -z_collar = Y_collar(:, 1); -z_dot_collar = Y_collar(:,2); -s_collar = z_0 - z_collar; - -z_brick = Y_brick(:,1); -z_dot_brick = Y_brick(:,2); -s_brick = z_0 - z_brick; - -%% plot 1 - hastighet -subplot(2,2,1); - -p1 = plot(s_collar, z_dot_collar); -p2 = plot(s_brick, z_dot_brick); -xlim([0 max(s_brick)]); -xlabel("Fallsträcka (m)"); -ylabel("Hastighet (m/s)"); -legend([p1 p2], {"Krage", "Kloss"}); -title("Hastighet"); - -%% plot 2 - acceleration -zdotdot_collar = zeros(length(t_vek_collar), 1); -for i=1:length(t_vek_collar) - zdotdot_collar(i) = -g - ((k/m)*z_collar(i)*(1-((3*b)/(2*sqrt((z_collar(i)^2) + (b.^2)))))); -end -subplot(2,2,2) -p3 = plot(s_collar, zdotdot_collar); -p4 = plot(s_brick, -g.*ones(length(s_brick), 1)); -xlim([0 max(s_brick)]); -xlabel("Fallsträcka (m)"); -ylabel("Acceleration (m/s^2)"); -legend([p3 p4], {"Krage", "Kloss"}, "Location", "southeast"); -title("Acceleration") - -%% plot 3 - normalkraft -subplot(2,2,3) -normal = b.*k.*((1-(3.*b))./(2.*sqrt((s_brick.^2) + (b.^2)))); -p1 = plot(s_brick, normal); -xlim([0 max(s_brick)]); -xlabel("Fallsträcka (m)"); -ylabel("Normalkraft (N)"); -title("Normalkraft") - -%% plot 4 - energi -T = (m.*(z_dot_collar.^2)./2; -V_g = m*g*z_collar; -V_e = k.*(sqrt((z_collar.^2) + (b.^2)) - (3.*b./2))./2; -E_tot = T + V_g + V_e; -subplot(2,2,4); -p5 = plot(s_collar, T); -p6 = plot(s_collar, V_g); -p7 = plot(s_collar, V_e); -p8 = plot(s_collar, E_tot); -xlim([0 max(s_collar)]); -xlabel("Fallsträcka (m)"); -ylabel("Energi (J)"); -legend([p5 p6 p7 p8], {"Rörelseenergi", "Potentiell energi", "Fjäderenergi", "Total energi"}); -title("Energi"); - -%% print -min(z_dot_collar) -min(z_dot_brick) - diff --git a/mek_upg.m b/mek_upg.m index 86532ce..f2eab57 100644 --- a/mek_upg.m +++ b/mek_upg.m @@ -6,13 +6,13 @@ clf set(gcf, 'Position', [50 50 1200 900]); stopheight=0; -g = 9.82; +g = 9.81; k = 100; m = 0.5; b = 0.3; t_max = 10; -z_0 = sqrt(3)*b; +z_0 = 0.5*sqrt(3)*b; %% calcs options_collar = odeset('Events', @(t,y) collar_events(t, y, stopheight), ... 'RelTol', 1e-3,'AbsTol', 1e-6, 'MaxStep', 0.01); @@ -34,15 +34,15 @@ s_brick = z_0 - z_brick; %% plot 1 - hastighet subplot(2,2,1); -p1 = plot(s_collar, z_dot_collar); +p1 = plot(s_collar, abs(z_dot_collar)); hold on; -p2 = plot(s_brick, z_dot_brick); +p2 = plot(s_brick, abs(z_dot_brick)); xlim([0 max(s_collar) + 0.05*max(s_collar)]); xlabel('Fallsträcka (m)'); ylabel('Hastighet (m/s)'); hold off; -legend([p1 p2], {'Krage', 'Kloss'}); -title('Hastighet'); +legend([p1 p2], {'Krage', 'Kloss'}, 'Location', 'southeast'); +title('Plot 9 - Hastighet'); %% plot 2 - acceleration zdotdot_collar = zeros(length(t_vek_collar), 1); @@ -58,28 +58,24 @@ xlabel('Fallsträcka (m)'); ylabel('Acceleration (m/s^2)'); hold off; legend([p3 p4], {'Krage', 'Kloss'}, 'Location', 'southeast'); -title('Acceleration') +title('Plot 10 - Acceleration'); %% plot 3 - normalkraft subplot(2,2,3) -normal = b.*k.*((1-(3.*b))./(2.*sqrt((s_brick.^2) + (b.^2)))); -p1 = plot(s_brick, normal); +normal = b.*k.*(1-((3.*b)./(2.*sqrt((z_collar.^2) + (b.^2))))); +p1 = plot(s_collar, normal); hold on; -xlim([0 max(s_brick) + 0.05*max(s_brick)]); +xlim([0 max(s_collar) + 0.05*max(s_collar)]); xlabel('Fallsträcka (m)'); ylabel('Normalkraft (N)'); -title('Normalkraft') +title('Plot 11 - Normalkraft'); hold off; %% plot 4 - energi -z_collar(end + 1) = z_collar(end); -z_dot_collar(end + 1) = 0; -s_collar(end + 1) = s_collar(end); - -T = abs((m.*(z_dot_collar.^2))./2); -V_g = abs(m*g*z_collar); -V_e = abs(k.*(sqrt((z_collar.^2) + (b.^2)) - (3.*b./2))./2); +T = (m.*(z_dot_collar.^2))./2; +V_g = m*g*z_collar; +V_e = (k/2)*(sqrt(z_collar.^2 + b^2) - (3*b/2)).^2; E_tot = T + V_g + V_e; subplot(2,2,4); p5 = plot(s_collar, T); @@ -92,9 +88,4 @@ xlabel('Fallsträcka (m)'); ylabel('Energi (J)'); hold off; legend([p5 p6 p7 p8], {'Rörelseenergi', 'Potentiell energi', 'Fjäderenergi', 'Total energi'}, 'Location', 'north'); -title('Energi'); - -%% print -min(z_dot_collar) -min(z_dot_brick) - +title('Plot 12 - Energi'); \ No newline at end of file diff --git a/plot_1.png b/plot_1.png new file mode 100644 index 0000000..1095fef Binary files /dev/null and b/plot_1.png differ diff --git a/plot_10.png b/plot_10.png new file mode 100644 index 0000000..8ffc8ce Binary files /dev/null and b/plot_10.png differ diff --git a/plot_11.png b/plot_11.png new file mode 100644 index 0000000..550002b Binary files /dev/null and b/plot_11.png differ diff --git a/plot_12.png b/plot_12.png new file mode 100644 index 0000000..ba2e2e4 Binary files /dev/null and b/plot_12.png differ diff --git a/plot_2.png b/plot_2.png new file mode 100644 index 0000000..540570a Binary files /dev/null and b/plot_2.png differ diff --git a/plot_3.png b/plot_3.png new file mode 100644 index 0000000..47b68e6 Binary files /dev/null and b/plot_3.png differ diff --git a/plot_4.png b/plot_4.png new file mode 100644 index 0000000..c8add4b Binary files /dev/null and b/plot_4.png differ diff --git a/plot_5.png b/plot_5.png new file mode 100644 index 0000000..cea46b7 Binary files /dev/null and b/plot_5.png differ diff --git a/plot_6.png b/plot_6.png new file mode 100644 index 0000000..5c6677c Binary files /dev/null and b/plot_6.png differ diff --git a/plot_7.png b/plot_7.png new file mode 100644 index 0000000..b9ac9fe Binary files /dev/null and b/plot_7.png differ diff --git a/plot_8.png b/plot_8.png new file mode 100644 index 0000000..7e37d30 Binary files /dev/null and b/plot_8.png differ diff --git a/plot_9.png b/plot_9.png new file mode 100644 index 0000000..afcfb70 Binary files /dev/null and b/plot_9.png differ