When I copy-and-paste your code into the MATLAB Editor it indicates two major syntax errors. Please use the Editor and use the syntax checking tool and pay attention to the highlighting and lines where error messages are displayed.
It looks like you might be using the syntax from another language, because the for , while and else statements do not have the required matching end statements. You really need to read the documentation for all of these operations, as the usage is quite different to what you have in your code. In any case you should avoid using loops for this kind of problem, and learn to use indexing properly. You also need to read about vectorization . Using MATLAB's powerful indexing and vectorizing the operations is what makes MATLAB code neat and fast. Learn to use them!
For example the log operation can be applied to all elements of a vector in one go:
vec = 25600:26000;
A = log(vec);
You also need to check the documentation for log and log10: did you actually mean to use log10 ?
You do not give any data or information about the "function" that you refer to, which makes it difficult to show you how you can check its values.
What do you mean by "create a new index in the matrix" ?