I enabled fft function in oscillioscope and it saved the data as FFT amplitude (dBV) and frequency domain how ever I want my time domain and ampltude signals original data.
2 ビュー (過去 30 日間)
古いコメントを表示
%%
folder = 'C:\Users\haneu\OneDrive\바탕 화면\New folder (2)';
filename = '550mvp.csv';
data = readtable(fullfile(folder,filename));
frequency = table2array(data(3:end,1));
amplitude = table2array(data(3:end,2));
figure,plot(frequency/1e6,amplitude)
xlim([0,15])
xlabel('Frequency [MHz]'),
grid on,
ylabel('Amplitude[dBV]')
0 件のコメント
採用された回答
Star Strider
2024 年 7 月 14 日
編集済み: Star Strider
2024 年 7 月 14 日
You cannot reliably invert a Fourier transforom unless you also have the phase information. Lacking the phase information, you can still invert it, however the result will not be reliable and may not reflect the actual time-domain signal. The best approach is to record the time-domain signal and calculate the Fourier transform afterwards.
One approach —
RL = readlines('550mvp.csv');
H1 = split(RL(1,:),',');
H2 = split(RL(2,:),',');
T1 = readtable('550mvp.csv', 'HeaderLines',2);
T1.Properties.VariableNames = H1.'
NrMissing = nnz(ismissing(T1))
T1 = fillmissing(T1, 'linear');
figure
plot(T1{:,1}, T1{:,2})
grid
xlabel(H2(1,:))
ylabel(H2(2,:))
L = height(T1)
Fn = max(T1{:,1}); % Nyquist Frequency
Fs = Fn*2; % Sampling Frequency
Ts = 1/Fs; % Sampling Interval
Lt = 2*L; % Assumed Length Of Original Time-Domain Signal
t = linspace(0, Lt-1, Lt)/Fs; % Time Vector
v = ifft([T1{:,2}; flip(T1{:,2})],'symmetric');
figure
plot(t, v)
grid
xlabel('Time')
ylabel('Volt')
xlim([min(t) max(t)])
figure
plot(t, v)
grid
xlabel('Time')
ylabel('Volt')
xlim([min(t) 1E-6])
This initially re-creates the full ‘original’ two-sided Fourier ttransform by appending a flipped version of the original one-sided Fourier transform to it and then doing the inversion. The highest frequency is assumed to be the Nyquist frequency here, and the sampling frequency and sampling intervals are calculatted from it.
.
EDIT — Corrected typographical errors.
EDIT — (14 Jul 2024 at 13:24)
Forgot the symmetry flag in the ifft call. Added now.
.
10 件のコメント
Star Strider
2024 年 7 月 16 日
Since your signals have a time vector, it is best to use it as an appropriate argument. (The only problem is tthat not all the time values are unique, so I use the resample function to create vectors that will work with pspectrum.) Note that tthis makes the time values the same as the argument times. The time values that pspectrum uses are still a bit strange (in my opinion, I have not explored that in detail) however they represent the time ranges in the argument vectors. I also plotted a sample of the original vectors to get an idea of what they looked like. This is close to the way I use pspectrum (generally using the default arguments, though).
Try this —
files = dir('*.csv');
for k = 1:numel(files)
filename = files(k).name
RL = readlines(filename);
H1 = split(RL(1,:),',');
H2 = split(RL(2,:),',');
data = readtable(filename, 'HeaderLines',2);
t = data{:,1};
x = data{:,2};
% time_resolution = t(end)-t(1);
% time_resolution = mean(diff(t));
zxi = find(diff(sign(x)));
fs = 1/mean(diff(t))
[xr, tr] = resample(x, t, fs);
figure
plot(tr, xr)
grid
xlabel('t')
ylabel('Volt')
title(filename)
xlim([-1 1]*2E-6)
figure
% pspectrum(x,fs,'spectrogram', ...
% 'FrequencyLimits',[1e5 7e6],'TimeResolution',time_resolution,'OverlapPercent',90)
pspectrum(xr, tr, 'spectrogram', 'FrequencyLimits',[1e5 7e6], 'OverlapPercent',90)
% Customize the plot
xlabel('Time (s)');
ylabel('Frequency (MHz)');
colormap("jet")
title('Spectrogram');
colorbar;
end
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with Signal Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!