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!