Programming Snafu's - My Numerical Analysis HW
4 views (last 30 days)
Show older comments
I am a total MatLab noobie and so I am unsure as how to approach or even solve these questions given by my prof, but perhaps if I could be pointed in the right direction that would be sufficient; here's his instructions and two problems:
INSTRUCTIONS
"Questions 5-10 are some common programming snafu's made in Matlab (believe me, I've made all of them and several times too!) In one or two sentences please identify the mistake in the function and explain (perhaps to your grandpa) how to remedy the problem (if a remedy is available)."
PROBLEMS
5. function y = whaterror1(x,n)
% Format y = whaterror1(x,n), with x and n both scalar
% This function contains what programming errors?
output = n*(x-2);
6. function y = whaterror2(x,n)
% Format y = whaterror2(x,n), with x and n both scalar
% This function contains what programming errors?
y = y + x*n
0 Comments
Accepted Answer
Matt Fig
on 3 Feb 2011
I would paste them into the MATLAB editor and read the warnings. Also, try to run the functions and see what happens! They will both error.
In the editor, the little orange lines on the right are warnings. Hover the mouse over them to see what they say.
0 Comments
More Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!