By assigning logical variables to expressions, the program gets automatic documentation. The construction will be easier to read and to debug.
if (value>=lowerLimit)&(value<=upperLimit)&~ismember(value,valueArray) :endshould be replaced by:
isValid = (value >= lowerLimit) & (value <= upperLimit);isNew = ~ismember(value, valueArray);if (isValid & isNew) :endThis practice improves readability by preventing exceptions from obscuring the normal path of execution.
fid = fopen(fileName);if (fid~=-1) :else :endMake sure that the exceptions don't obscure the normal path of execution. Using the block comment feature of the editor is preferred.
Leaving the otherwise out is a common error, which can lead to unexpected results.
switch (condition) case ABC statements; case DEF statements; otherwise statements;endCharacter strings work well in this context and they are usually more meaningful than enumerated cases.