Latest LQ Deal: Latest LQ Deals
 LinuxQuestions.org problem with MATLAB 6.1
 Linux - General This Linux forum is for general Linux questions and discussion. If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

 06-19-2004, 10:36 AM #1 illiniguy3043 Member   Registered: May 2004 Location: Illinois Distribution: Ubuntu 8.04 Posts: 56 Rep: problem with MATLAB 6.1 I need to find the distance between 2 peaks of a periodic function in a graph in MATLAB 6.1 and I can't figure out how to do it precisely. I know I can look at the plot and figure out where maxes and mins are and look at the corresponding places in the data but that kinda defeats the purpose of plotting it to find the period. Anyone have any ideas as to how to do it graphically? I know this isn't really a Linux question but I am running this on Linux and all the MATLAB message boards suck and I know a lot of people read this
 06-19-2004, 08:21 PM #2 bdp Member   Registered: Apr 2002 Distribution: RH 9 Posts: 230 Rep: this should work for simple trancendentals: data=[1 3 1 3 1 3 1 3 1 3 1 3]; fnMax=max(data); i=find(data==fnMax); apparantPeriod=i(2)-i(1); disp(['Period is ' num2str(apparantPeriod)]); % to avoid aliasing you need to work out your X-axis vector spacing or fit parabolas across every triplet obviously for real functions you'll need to FFT it, i'll paste in some code i use for this to get you started, sorry if it's a mess if (FLast-FFirst)<16 resol=16; elseif (FLast-FFirst)<32 resol=32; elseif (FLast-FFirst)<64 resol=64; end FFirst=data(1);FLast=size(data); FRange=FFirst:FLast; temp1=detrend(data); spec=fft(temp1(,resol); pow = (spec.*conj(spec))/resol;loglog(freq,pow(1:resol/2)); title(['x= ',num2str(j),', y= ', num2str(k) ' Power Spectrum of ',ytit,' (x,y Measured from top left)',' Clip ', FileName, ' Frame Range =' num2str(FFirst),':',num2str(FLast)],'FontName',Font1Name);grid; xlabel('Frequency (s-1)','FontName',Font1Name); figure(11);plot(freq,pow(1:resol/2));%axis([-inf inf 1e-5 1e2]); title(['x= ',num2str(j),', y= ', num2str(k) ' Power Spectrum of ',ytit,' (x,y Measured from top left)',' Clip ', FileName, ' Frame Range =' num2str(FFirst),':',num2str(FLast)],'FontName',Font1Name);grid; xlabel('Frequency (s-1)','FontName',Font1Name); Last edited by bdp; 06-19-2004 at 08:29 PM.
 06-19-2004, 11:45 PM #3 illiniguy3043 Member   Registered: May 2004 Location: Illinois Distribution: Ubuntu 8.04 Posts: 56 Original Poster Rep: What does the mean in the line where you assign what spec means?
 06-20-2004, 04:09 PM #4 bdp Member   Registered: Apr 2002 Distribution: RH 9 Posts: 230 Rep: sorry, the smiley is a 'semicolon right_paren' and can be changed to something like 20:55 to only take data in that range. essentially all that code does is try to find the nyquist frequency to avoid showing a frequency power spectrum that mirrors at some value of x, that's what 'resol' is all about. for the meat of it, just take the FFT times the complex conjugate of the FFT to put it in real space and scale accordingly. the FFT period is in units of the length of the data set which is why resol shows up later. sorry i didn't organize it before posting, it looks a bit out of order. cheers, -bp

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post rcnow Linux - Software 11 05-10-2007 04:41 AM sourangshu Linux - Software 0 07-08-2005 02:04 PM fubzot Linux - Software 2 02-15-2005 07:49 AM IBall Linux - Software 0 08-31-2004 04:05 AM safrout Programming 3 04-13-2002 04:36 PM

LinuxQuestions.org

All times are GMT -5. The time now is 07:38 AM.

 Contact Us - Advertising Info - Rules - Privacy - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -