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!