us Text-File von Lt_spice in Matlab FFT

#5668087
Lesenswert?

Hallo,

Ich nehme eine periodische Zeitsignal von LT_Spice als Text-File und 
möchte ich mit Matlab extern die Interpolation und FFT mache, um die 
Ergebnisse zu vergleichen.
Die Hilfe von Matlab über FFT und vq = interp1(x,v,xq) habe ich gelesen 
und habe ich versucht in Matlab FFT mache, leider konnte ich nicht zu 
Recht kommen.

Kann jemand mir bitte sagen, wie ich aus Text-File von Lt_spice in 
Matlab FFT machen kann?

Für Hilfe wäre ich sehr dankbar.

Viele Grüße
Angehängte Dateien:
Gast #5669283
Lesenswert?

Erst mal die Ausgabe von LTSpice prüfen. Dazu versuche die Datei in 
Office einzulesen und als csv abzuspeichern. Wenn dabei vernünftige 
Zahlenreihen vorliegen, erst dann macht es Sinn sich mit Matlab zu 
befassen.
#5670732
Lesenswert?

Hier ein Beispiel

% FFT with Matlab
fileid = fopen("test_t.txt",'r'); % open file for read
% h_text = textscan(fileid,'%s',2) % read the two word header from 
LTspice-exported file
[a n]=fscanf(fileid,"%e");      % a data, n size of a
fclose(fileid);
x = a(1:2:n-1);                 % x-values
y = a(2:2:n);                   % y values
n_fft = 16384;                  % size for the FFT
tmax = 10e-6;                   % time 0 to tmax
t = linspace(0,tmax,n_fft+1);   % time vector 0 to 10us
z = interp1(x,y,t(1:n_fft));    % interpolate y-values
zfft = fft(z,n_fft)/(n_fft/2);  % FFT
zfftabs = abs(zfft(1:(n_fft/2))); % absolute values
zfftabs(1) = zfftabs(1)/2;      %  value at DC-value, f=0Hz
f0 = 1/tmax;                    % base frequency
f = f0*linspace(0,n_fft/2-1,n_fft/2);  % frequency vector, f = 0 to 
f0*(n_fft/2-1)
zfftabsdB = 20*log10(zfftabs);  % absolute values in dB
% plot(f,zfftabs)
% plot(f(1:10),zfftabsdB(1:10),'*') % '+' '-' '.'
% line(f(1:10),zfftabsdB(1:10))     '

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren