2.0

2.0 | 4 ratings Rate this file 284 downloads (last 30 days) File Size: 13.2 KB File ID: #22200

maxima and minima

by aasim Azooz

 

21 Nov 2008 (Updated 29 Nov 2008)

M-files for obtaining extreme points is a set of data

Download Now | Watch this File

File Information
Description

These are two similar programs. They operate to find coordinates and indices of extreme points in a set of x,y data. they are usful for a purposes ranging between finding positions where the first derivative is zero to obtaining envelops of signals. Example is given in the attached pdf file  

MATLAB release MATLAB 6.5 (R13)
Zip File Content  
Other Files maxima.pdf,
minima.m,
maxima.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
23 Nov 2008 Felix Zoergiebel Sorry, I accidentally gave the three star rating. Well, since I rated it: 
I tested the code, it works. However I'd recommend to rewrite the code with some find commands instead of the for loop. That's less code and executes faster. 
24 Nov 2008 Duane Hanselman By including a plot command inside these functions, you force users to accept a plot of the results. Why do this when many users may not want a plot? 
No help text or comments of any kind. 
No error checking of any kind. 
No use of vectorization. 
Not much use for anyone except the author.
25 Nov 2008 aasim Azooz Dear Duane Hanselman  
If you do not want the plot, you can close it or simply deactivate the plot command with %  
Please go to the pdf file for instructions and help
25 Nov 2008 Duane Hanselman Dear aasim Azooz 
The help belongs in the M-file itself, just as it appears in all functions distributed with MATLAB and all good files posted here. Why would a person want a thousand pdf files to document a thousand M-files?
25 Nov 2008 Dr Anonymous I agree with Duane, 
I wouldn't like to search a pdf first before being able to use a function. You?  
25 Nov 2008 aasim Azooz Dears Dr Anonymous and Duane Hanselman  
Well I can easly add few comment but I will not green comments do more harm than good. It is a matter of taste. please Look at the download rate for the last four days. They changed my rank from 720 to 523.
25 Nov 2008 Kenneth Eaton The number of downloads is not a real measure of the QUALITY of the submission, merely the amount of CURIOSITY users have regarding your submission. Remember, many people can't help but stare at a car wreck. 
 
You should heed the advice of the other commenters. Your statement that "comments do more harm than good" is incredibly foolish. You should look at how typical MATLAB files are written and modify your submission accordingly.
26 Nov 2008 Duane Hanselman If help text and comments contained inside an M-file do more harm than good, then I suggest that you make an official enhancement request to The Mathworks asking them to remove all such harmful text from the thousands of M-files they distribute with MATLAB. Even better yet, request that they eliminate the % symbol as the start of a comment in an M-file. That will make it impossible for anyone to include such harmful material in an M-file. The % symbol marking a comment might have been around for 25 years in MATLAB, but it is never too late to get rid of it.
28 Nov 2008 aasim Azooz Dear every one  
I have been looking at all your comments. please do not take what I wrote out of context. I still maintain that few lines of green comments may do more harm to a five statments program than good. I think that the % sign is very useful in long codes but not as much in short ones. In my case, I have included all explaination and an example in the pdf file I do not know how to do that with the % if any of you can teach me how to do it, I shall be grateful to him. Otherwise, he can try to be fair at least. Thanks to all  
Aasim Azooz
28 Nov 2008 Jos Somehow, I feel you miss the point completely. It is perfectly acceptable to have a separate document describing your functions in detail. However, you have to be aware how people will use your function. When they type "help maxima" and nothing is returned, it is most likely they will never use it and even delete it. In the very best case they will modify the function to include a help section.  
 
So, try to make a proper help section within the function itself using the comment symbol, and include a H1 line, the calling syntax and an example. In addition, you could refer to your pdf-document. Furthermore, comment your code, explaining in normal language what each statement is doing.  
 
Note that comment lines do not affect the speed or execution of the code in any way. It is intended to assist the user, and the developer as well, when the need arises for understanding or updating the function.
29 Nov 2008 aasim Azooz Thank Jos. I understand what you mean. I will keep your advice in mind. I think other folks and my self have made an issue out of silly thing. I will edit the file. Many thanks  
Aasim Azooz
Please login to add a comment or rating.
Updates
29 Nov 2008 Comments are added describing the M-files and the function of each step

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com