Clear Filters
Clear Filters

How to plot all impedances at harmonic frequencies in one graph

1 view (last 30 days)
My loop program is as attached:
for ftemp=5:5:130 fharmonics=ftemp/60; sim('power_wind_type_4_det_1409.slx') save 'impedanceatharmonics_ftemp'num2str(ftemp)'.mat' ; load 'impedanceatharmonics_ftemp'num2str(ftemp)'.mat'; figure hold on impedanceatharmonics end
my main program is :
%for voltage t=Vabc575.time; %t is simulation time v=Vabc575.signals.values; %y is the three phase voltage over simulation period L=1500000;%L is length of signal which is multiplication of total simulation time and sampling frequency m1=v(:,1); %m1 is magnitude of phase a Vmag=fft(m1); %fft of magnitude of phase a Ts=2e-06; %Ts sampling time Fs=1/Ts; %Fs sampling frequency Vmagfinal = abs(2.*Vmag./L); Vmag1 = Vmagfinal(1:L/100+1); df=Fs/length(t); %ratio of sampling frequency and no. of samples freq=0:df:Fs/100; %frequency to be displayed in plot, sample frequency is 500000,to bring in the range of 100 we are dividing by 5000 f=freq.'; % converting row of frequency into column [x]=find(f>= ftemp-0.33 & f ftemp+0.33, 1, 'last'); vftemp=Vmag1(x);% extracting the magnitude at ftemp(harmonics) idx = (t 2 & t <= 3); subplot(3,2,1), plot(t(idx),m1(idx)), title('output voltage waveform'), xlabel('time'), ylabel('Voltage amplitude'); % plot of voltage waveform subplot(3,2,2), (stem(f,Vmag1)); title('fft of voltage waveform'), xlabel('frequency'), ylabel('magnitude'); % plot of FFT of voltage wave
%for current t1=Iabc575.time; %t is simulation time i=Iabc575.signals.values; %y is the three phase voltage over simulation period L=1500000;%L is length of signal which is multiplication of total simulation time and sampling frequency m2=i(:,1); %m2 is magnitude of phase a current Imag=fft(m2); %fft of magnitude of phase a Ts=2e-06; %Ts sampling time Fs=1/Ts; %Fs sampling frequency Imagfinal = abs(2.*Imag./L); Imag1 = Imagfinal(1:L/100+1); df=Fs/length(t1); %ratio of sampling frequency and no. of samples freq=0:df:Fs/100; %frequency to be displayed in plot, sample frequency is 500000 to bring in the range of 100 we are dividing by 5000 f=freq.'; % converting row of frequency into column [w]=find(f >= ftemp-0.33 & f ftemp+0.33, 1, 'last'); iftemp=Imag1(w); %extracting the magnitude at ftemp(harmonics) idx1 = (t1 2 & t1 <= 3); subplot(3,2,3), plot(t1(idx1),m2(idx1)), title('output current waveform'), xlabel('time'), ylabel('current amplitude'); % plot of current waveform subplot(3,2,4), (stem(f,Imag1)); title('fft of current waveform'), xlabel('frequency'), ylabel('magnitude');% plot of FFT of voltage wave
%for impedance t=Vabc575.time; %t is simulation time L=1500000;%L is length of signal which is multiplication of total simulation time and sampling frequency Vrms = vftemp./1.41; Irms=iftemp./1.41; zftemp=(Vrms./Irms); %m3 is impedance %Z=z3*ones(15001,1); Ts=2e-06; %Ts sampling time Fs=1/Ts; %Fs sampling frequency dftemp=ftemp; %ratio of sampling frequency and no. of samples %freq=0:df3:Fs/100; %frequency to be displayed in plot, sample frequency is 500000,so to bring in the range idx = (t> 2 & t <= 3); subplot(3,2,5), (stem(dftemp,zftemp)); title('fft of impedance waveform'), xlabel('frequency'), ylabel('magnitude'); % plot of FFT of voltage wave
Here if I run the loop program I am getting 26 graphs from 5Hz to 130Hz (Harmonic frequency) and getting impedance for individual frequency but I want to plot the graph in which x axis should be the harmonic frequencies and y axis should be impedance.At the end after getting all the points I need to make a line joining all the peak points.
Kindly suggest me the way to do that.

Answers (0)

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!