How do I Waveform,FFT that data?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
Walter Roberson
2018년 5월 7일
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
2018년 5월 7일
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
2018년 5월 7일
Ameer Hamza
2018년 5월 7일
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.
답변 (0개)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!