MATLAB is case-sensitive, so m ~= M.
You have several problems, however. You use both ‘m’ and ‘M’ in different contexts in your code.
I would initially reassign ‘M’ as:
but then you need to decide what you want to do with:
because this now creates a matrix ‘M’, using ‘m’ to calculate it.
You later assign:
and use it to calculate:
z = m * abs(frame(1:n2,:)).^2;
further confusing the issue. You can see how MATLAB would get confused, much as I would be confused if I didn’t switch contexts, and I’m quite definitely not certain what you’re referring to. Eliminate the ambiguities and all will be well. I would use different variable names and assignments as necessary to avoid confusion and make your code easier to follow. MATLAB does not restrict you to specific variable name lengths (providing you don’t overdo it), so ‘M_constant’, ‘M_matrix’ and ‘final_result’ are all both valid and descriptive. The typing can get tedious, but that’s the worst that can be said about it.
I would also comment-document it, because that will help you understand what you’re doing, will tell other people what you’re doing, and you will need those descriptions when you come back to your code in a while and have to figure out what you were thinking. (Believe me, you won’t remember the details in a few days and especially in a few weeks.)
LATER THAT SAME MINUTE — I see some other problems and inefficiencies, but lets get the ‘M,m’ problem sorted first.