我有时间(第1列)和当前幅度(第2列)的csv数据。我想绘制电流的FFT。这实际上是超过30ns的模拟数据,数据步长是1ps。我可以在MATLAB中绘制当前与时间的关系。但是在进行FFT功能时,它根本就没有绘图
Error using plot Vectors must be the same length. Error in FFT_Ideal_current_maxstep_1ps (line 25). plot(f,Y)
任何人都可以帮助我吗?我也附上了MATLAB代码和CSV文件。
我还想绘制功率谱密度。如果有人能提供帮助,那就太好了。我想获得超过2GHz或更高频谱范围的FFT和psd
MATLAB code1:
% open data file
fid = fopen('current_maxstep_1ps.csv');
% Read data in from csv file
readData = textscan(fid,'%f %f','Headerlines',1,'Delimiter',',');
% Extract data from readData
t = readData{1,1}(:,1);
x = readData{1,2}(:,1);
N = length(x);
ts = 0.000000000001;
Fs = 1/ts;
tmax = (N-1)*ts;
tm = 0:ts:tmax;
f = 0:Fs/(N-1):Fs/2;
y = fftshift(fft(x));
Y = abs(y);
plot(f,Y)
还有另一个我试过的MATLAB代码,它绘制了一个图(这里是图片:FFT picture of code 2),但在时域中显示,我想要频谱像频谱上的apmitudes尖峰。
MATLAB Code2:
% open data file
fid = fopen('Ideal_current_maxstep_1ps.csv');
% Read data in from csv file
readData = textscan(fid,'%f %f','Headerlines',1,'Delimiter',',');
% Extract data from readData
xData = readData{1,1}(:,1);
yData = readData{1,2}(:,1);
Ts = 1e-12;
Fs = 1/Ts;
%Fs = 1000;
%Ts = 1/Fs;
X = fft(yData);
plot(xData, abs(X))