Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Hint about Matlab algorithm?
Note: Please do not give me answers to the problem. I'd really like to figure out the actual answer by myself. I have no programing/coding experience, so I'm having trouble even thinking about where to start with this problem though, so a hint as to a process I should follow would be really great! I'm thinking I need to use a for loop of some sort, but past that, I don't have the faintest clue where to go.
The following expression is exactly equal to zero:
200 - Sigma(i=1 to 2,000) 0.1 =0
Write a MATLAB algorithm to compute the expression above by repeated subtraction, and compare the answer to the exact answer of zero. In other words, compute the absolute value of the error between MATLAB’s answer and zero. (Hint: use the abs() command.)
1 Answer
- ooorahLv 67 years agoFavorite Answer
In general, if you have a summation expression, it looks like this:
Sigma(from indexVariable = startValue to endValue) [some expression]
The MATLAB equivalent would be:
total = 0;
for indexVariable = startValue:endValue
total = total + ...some expression, possibly a function of indexVariable...
end
fprintf('Total = %.3f\n', total) % Not necessary, just for showing result
Yours is a little different because it seems like you want to do:
result = 200 - 0.1;
result = result - 0.1;
result = result - 0.1;
...repeat 2000 times
compare result to 0.
So you'll just change the expression inside the for loop. Also, your expression won't depend on the index variable at all.