Hello everyone, I'm implementing a matlab code that realizes the space vector modulation for a three-phase inverter. One of the points required is the representation of the spectrum of inverter output voltage.
I wrote the following code:
I later called up as follows:
Simout is a signal that I take from a scope of simulink.
I get the attached graph.
This chart is not correct, because I should do the FFT of the sine wave (omitting the transient) and then the teacher told me to take an integer number of periods.
I am not able to do so. Could you please help me?
Thanks in advance
Ps: sorry for my english
I wrote the following code:
Rich (BB code):
function out=spettro(ValoreNelTempo,IntervalloTempo,fmax)
dime = max(size(ValoreNelTempo));
f0 = 1/IntervalloTempo;
n = floor(fmax/f0);
if (n>dime)
n=dime-1;
end
ValoreNelTempo=reshape(ValoreNelTempo,dime,1);
tempo = linspace(0,IntervalloTempo,length(ValoreNelTempo));
a=fft(ValoreNelTempo);
Armoniche=2*abs(a(2:dime))/dime;
numarm=1:n;
figure(1), subplot(2,1,1)
bar(numarm*f0,Armoniche(numarm),0.5,'r')
xlabel('frequenza - Hz'),grid
figure(1), subplot(2,1,2)
plot(tempo,ValoreNelTempo,'b-');
xlabel('tempo - s'), grid
out=Armoniche(numarm);
Rich (BB code):
tempo = simout.time;
% tempo= t(time>0.3)
y = simout.signals.values;
% signal_mod= y(time>0.3)
out = spettro(y,max(tempo),2/Ts);
figure(1),
subplot(2,1,1), ylim([0 40]), xlim([0 100])
legend('spettro del segnale campionato')
subplot(2,1,2), ylim([-100 100]), xlim([0 2])
legend('laura')
I get the attached graph.
This chart is not correct, because I should do the FFT of the sine wave (omitting the transient) and then the teacher told me to take an integer number of periods.
I am not able to do so. Could you please help me?
Thanks in advance
Ps: sorry for my english
Attachments
-
120.8 KB Views: 15