gistlib
main.m% Load the measured vibration data data = load('vibration_data.txt'); % Perform frequency analysis to determine natural frequencies Fs = 1000; % Sampling frequency Y = fft(data); L = length(data); P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1); f = Fs*(0:(L/2))/L; % Identify peaks to determine natural frequencies [~,locs] = findpeaks(P1,'MinPeakHeight',threshold); natural_frequencies = f(locs); % Perform modal analysis to determine mode shapes mode_shapes = zeros(length(natural_frequencies), length(data)); for i=1:length(natural_frequencies) [b,a] = butter(4, [2*(natural_frequencies(i)-1)/Fs, 2*(natural_frequencies(i)+1)/Fs], 'bandpass'); filtered_data = filtfilt(b, a, data); [~,locs] = findpeaks(filtered_data, 'NPeaks', 2); mode_shapes(i, locs) = 1; end % Visualize mode shapes for i=1:length(natural_frequencies) figure; plot(mode_shapes(i,:)); title(['Mode shape at frequency: ' num2str(natural_frequencies(i)) ' Hz']); end 983 chars32 lines
% Load the measured vibration data data = load('vibration_data.txt'); % Perform frequency analysis to determine natural frequencies Fs = 1000; % Sampling frequency Y = fft(data); L = length(data); P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1); f = Fs*(0:(L/2))/L; % Identify peaks to determine natural frequencies [~,locs] = findpeaks(P1,'MinPeakHeight',threshold); natural_frequencies = f(locs); % Perform modal analysis to determine mode shapes mode_shapes = zeros(length(natural_frequencies), length(data)); for i=1:length(natural_frequencies) [b,a] = butter(4, [2*(natural_frequencies(i)-1)/Fs, 2*(natural_frequencies(i)+1)/Fs], 'bandpass'); filtered_data = filtfilt(b, a, data); [~,locs] = findpeaks(filtered_data, 'NPeaks', 2); mode_shapes(i, locs) = 1; end % Visualize mode shapes for i=1:length(natural_frequencies) figure; plot(mode_shapes(i,:)); title(['Mode shape at frequency: ' num2str(natural_frequencies(i)) ' Hz']); end
gistlibby LogSnag