Programming Snafu's - My Numerical Analysis HW

7 visualizaciones (últimos 30 días)
Victor
Victor el 3 de Feb. de 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

Respuesta aceptada

Matt Fig
Matt Fig el 3 de Feb. de 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.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by