%% % MODIFICATION OF: Surgical Robot data file viewer % Analyzes data from the Vibrotactile stimulus verifier. plot_title = 'VSV Data Analysis'; delimiter = ' '; % Change for what your files use % Constants n = 1; % Start file counter at 1 Fs = 2560; % Sampling frequency T = 1/Fs; % Sample time PRINT = 1; % Print? 0 = No, 1 = Yes LOWFREQT = 0.0; % Low frequency cutoff (Top plot) LOWFREQB = 0.0; % Low frequency cutoff (Bot plot) % Create array of all data files in current directory fNames = dir(fullfile('.','trial*.txt')); filename = 'output.txt'; % Open data file and read in data fid = fopen(filename); file_data = fscanf(fid, '%d', [1 inf]); fclose(fid); % Split up data time = file_data(1,:); L = length(time); % Pad force vectors NFFT = 2^nextpow2(L); % Perform FFT on each force axis and set DC component to 0 fft_time = fft(time,NFFT)/L; fft_time(1)=0; % Time vector t = (0:L-1)*T; f = Fs/2*linspace(0,1,floor(NFFT/2)); fig = figure(1); % Plot force waveforms subplot(2,1,1); plot(time, 'r'); set(gca, 'FontSize', 18); h = title(plot_title); set(gca, 'FontSize', 8); xlabel('Samples (2056Hz)'); ylabel('Acceleration'); %legend('X', 'Y', 'Z',3); %legend('boxoff'); % Plot frequency spectrum of X-axis subplot(2,1,2); plot(f, 2*abs(fft_time(1:floor(NFFT/2))), 'r'); set(gca, 'FontSize', 8); hold off; xlabel('Temporal frequency (Hz)'); ylabel('FFT Magnitude (X-axis)');