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
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.
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
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.
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.
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.
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?
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.
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.
29 Nov 2008
Comments are added describing the M-files and the function of each step