How do I Waveform,FFT that data?
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
I want to display the file as Waveform, FFT.(The attached file)
But I think my coding has a problem.
Can you look at it? I want to set the frequency in MHz
clear all; close all; clc;
[filename directory_name] = uigetfile('*.dat', 'Select a file');
fullname = fullfile(directory_name, filename);
data = load(fullname);
t = data(:,1)*1e-3; % Convert To‘seconds’ From ‘milliseconds’
v = data(:,2); % Voltage
L = length(t);
Ts = mean(diff(t)); % Sampling Interval (sec)
Fs = (1/Ts)*1e6; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
vc = v - mean(v); % Subtract Mean (‘0 Hz’) Component
FTv = fft(vc, L*4)/L; % Fourier Transform
Fv = linspace(0, 1, fix(length(FTv)/2)+1)*Fn; % Frequency Vector (Hz)
Iv = 1:length(Fv); % Index Vector
subplot(2,1,1);
plot(t,v);
title('Waveform');
xlabel('Time domain[ms]');
ylabel('Amplitude[mV]');
grid on;
subplot(2,1,2);
plot(Fv, abs(FTv(Iv))*2)
title('Spectrum');
xlabel('Frequency[MHz]');
ylabel('Magnitude[dB]');
grid on;
4 comentarios
Walter Roberson
el 7 de Mayo de 2018
What is the difference between this question and https://www.mathworks.com/matlabcentral/answers/399456-i-want-to-display-the-attachment-as-waveform-fft ?
Ameer Hamza
el 7 de Mayo de 2018
The first column of your data does not seem to represent time. It contains negative values. Also, the time samples are very close, what is the sampling frequency of the signal.
milksba
el 7 de Mayo de 2018
Ameer Hamza
el 7 de Mayo de 2018
Yes, but how come the time is negative. Also, sampling frequency seems to be very large (in GHz). How can you display it in MHz.
Respuestas (0)
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!