Prev: xlswrite
Next: matrix import
From: Mehmet Demirtas on 25 Apr 2010 16:14 Hi all, I have a signal vector (Fase1vuoto1) with length(Fase1vuoto1). I would like to obtain power/frequency values of each frequency component. I used Hpsd=dspdata.psd(...) function and i can obtain the Frequency versus Power/frequency plot. But, i need them in two different vectors. How can i obtain such vectors one for frequency, one for power/frequency. Fs=5000; nfft=2^nextpow2(length(Fase1vuoto1)); Pxx=abs(fft(Fase1vuoto1,nfft)).^2/length(Fase1vuoto1)/Fs; % Create a one-sided spectrum Hpsd=dspdata.psd(Pxx(1:length(Pxx)/2),'SpectrumType','Onesided','Fs',Fs); figure(1) plot(Hpsd) I need to obtain all frequency values in a vector and Power/frequency values in another vector...
From: Sadik on 25 Apr 2010 16:29 Hi Mehmet, One solution is that after you have your plot, you could obtain the handle to the [blue] line object in the plot and then get its XData [which will be the frequency values] and YData [which will be the power/frequency values]. Something like this: [You may need to modify the code a bit] h = findobj('type','line'); freq = get(h, 'XData'); powerOverFreq = get(h,'YData'); If you have put a legend on your plot or due to some other reason h is an array rather than a scalar, you can select the elements of it to use in get, just like: freq = get(h(2),'XData'); Best.
From: Mehmet Demirtas on 25 Apr 2010 18:41 Hi Sadik, Thank you for your reply. I checked matlab help for the usage of findobj function but i didn't understand it... how can i implement it in my code? could you please help me?
From: Mehmet Demirtas on 25 Apr 2010 18:50 After running the m-file, in Matlab command window when i type Hpsd, i get: Hpsd = Name: 'Power Spectral Density' Data: [8192x1 double] SpectrumType: 'Onesided' NormalizedFrequency: false Fs: 5000 Frequencies: [8192x1 double] ConfLevel: 'Not Specified' ConfInterval: [] So, how can i implement the findobj function in this case? Sorry, i am a Matlab newbie... i would be grateful if you help me...
From: Sadik on 25 Apr 2010 19:51 Hi Mehmet, I suggested a solution as a reply to your mail. Please check your inbox. Best.
|
Pages: 1 Prev: xlswrite Next: matrix import |