Programming Snafu's - My Numerical Analysis HW

7 vues (au cours des 30 derniers jours)
Victor
Victor le 3 Fév 2011
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

Réponse acceptée

Matt Fig
Matt Fig le 3 Fév 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.

Plus de réponses (0)

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by