MATLAB programing

zyad
Shakercode.m

clc clear all close all load('C:\Users\kvnj1\OneDrive\Documents\Junior\ME 392\Lab5\shaker.mat') outputvoltage = output_voltage; inputvoltage = input_voltage; N = size(outputvoltage,2); time = [0:(N-1)]*dt; % time vector freq = time/(dt*dt*N); % frequency vector accel=outputvoltage*(1/10.47)*1000; ACCEL = 2/N*fft(accel'); INPUTVOLTAGE = 2/N*fft(inputvoltage'); inputfreq = 50; for nn = 1:size(outputvoltage,1) [~, index1] = find(freq-inputfreq >= 0); [~, index2] = find(freq-inputfreq <= 0); peak_out(nn) = max(abs(ACCEL(index1(1),nn)),abs(ACCEL(index2(end),nn))); peak_in(nn) = max(abs(INPUTVOLTAGE(index1(1),nn)),abs(INPUTVOLTAGE(index2(end),nn))); end figure plot(peak_in,peak_out,'o') xlabel('V_i_n (V)') ylabel('Acceleration (m/s^2)') figure plot(time,ACCEL,'o') xlabel('Time (s)') ylabel('Acceleration (m/s^2)') velocity=cumsum(ACCEL)*dt disp=cumsum(velocity)*dt figure plot(time,velocity,'o') xlabel('Time(s)') ylabel('Velocity (m/s)') figure plot(time,disp,'o') xlabel('Time(s)') ylabel('Displacement(m)')