Question: please fix and solve the issue my matlab code project : % Mike _ id _ Project _ main.m : I dont not have to
please fix and solve the issue my matlab code project : MikeidProjectmain.m : I dont not have to use structures, and it does not allow separate assignments on the "trials" variable.
You can just create different variable arrays for m k and c and call mi ki and ci during each trial run.
For the animation part, please remember that since the framerate is while dt is that would mean frame every iterations.
Therefore, on line the for loop should state a manual stepsize of : MataJocelynProjectmain.m clear; close all; clc; Trial Parameters trials structmasskc; structmasskc; structmasskc; Simulation Parameters t; Initial time tf ; Final time dt ; Time step fps ; Frames per second x; Initial position v; Initial velocity a; Forcing amplitude Iterate through trials for trial :lengthtrials Extract trial parameters m trialstrialmass; k trialstrialk; c trialstrialc; Time array t t:dt:tf; Preallocate arrays for position and velocity xhomogeneouseuler zerossizet; vhomogeneouseuler zerossizet; xinhomogeneouseuler zerossizet; vinhomogeneouseuler zerossizet; xhomogeneousrk zerossizet; vhomogeneousrk zerossizet; xinhomogeneousrk zerossizet; vinhomogeneousrk zerossizet; Set initial conditions xhomogeneouseuler; vhomogeneouseuler v; xinhomogeneouseuler x; vinhomogeneouseuler v; xhomogeneousrk x; vhomogeneousrk v; xinhomogeneousrk x; vinhomogeneousrk v; Simulate for each time step for i :lengtht Homogeneous Ftxhomogeneouseuleri vhomogeneouseuleri VibrationPosition xhomogeneouseuleri vhomogeneouseuleri m k c dt; xhomogeneousrki vhomogeneousrki VibrationPosition xhomogeneousrki vhomogeneousrki m k c dt; Inhomogeneous Ft a sintpi finhom a sinti pi; xinhomogeneouseuleri vinhomogeneouseuleri VibrationPosition xinhomogeneouseuleri vinhomogeneouseuleri m k c finhom, dt; xinhomogeneousrki vinhomogeneousrki VibrationPosition xinhomogeneousrki vinhomogeneousrki m k c finhom, dt; end Plotting results figurePosition; Euler Method Subplot subplot; plott xhomogeneouseuler, b 'LineWidth', ; titleTrial numstrtrial Homogeneous Euler; xlabelTime s; ylabelPosition m; grid on; subplot; plott xinhomogeneouseuler, r 'LineWidth', ; titleTrial numstrtrial Inhomogeneous Euler; xlabelTime s; ylabelPosition m; grid on; Save figure saveasgcfTrial numstrtrialEuler.fig'; close; RK Method Subplot figurePosition; subplot; plott xhomogeneousrkb 'LineWidth', ; titleTrial numstrtrial Homogeneous RK; xlabelTime s; ylabelPosition m; grid on; subplot; plott xinhomogeneousrkr 'LineWidth', ; titleTrial numstrtrial Inhomogeneous RK; xlabelTime s; ylabelPosition m; grid on; Save figure saveasgcfTrial numstrtrialRKfig'; close; Animation Generation figurePosition; Homogeneous Response Animation subplot; h animatedlineColorb 'LineWidth', ; titleTrial numstrtrial Homogeneous'; xlabelTime s; ylabelPosition m; xlimt tf; ylimminxhomogeneouseuler, xhomogeneousrk maxxhomogeneouseuler, xhomogeneousrk; grid on; Inhomogeneous Response Animation subplot; h animatedlineColorr 'LineWidth', ; titleTrial numstrtrial Inhomogeneous'; xlabelTime s; ylabelPosition m; xlimt tf; ylimminxinhomogeneouseuler, xinhomogeneousrk maxxinhomogeneouseuler, xinhomogeneousrk; grid on; Create video writer v VideoWriterMikeidvideo numstrtrial 'MPEG
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
