I Truly appreciate if somebody check my code. I should measure a parameter of a long vector and I have wrtten the code but my prof. says it is something wrong. I am new in MATLAB:( .Thank you.
No, because sum of the result is not taken. You get a local result at each point.
Because of the way the equation is structured, the easiest way to correct the problem is to remove the leading 1/2. Each of the mean involves dividing by 2 but because you are dividing by that the effect is a multiplication by 2 when you leave out the division by two. The denominator is the sum of two terms that each have this issue, so the multiplication is in common and can be factored out. This leads to 1/2 times 2 times the + that has the divisions omitted and the 1/2 and 2 cancel. Therefore remove the 1/2 will give a mathematical correction.
Of course instead putting the divisions by 2 into the code will give you code that is easier to match to the formula...
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
2 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/716608-simple-equation-writing-formula#comment_1262573
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/716608-simple-equation-writing-formula#comment_1262573
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/716608-simple-equation-writing-formula#comment_1263148
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/716608-simple-equation-writing-formula#comment_1263148
Sign in to comment.