Programming Snafu's - My Numerical Analysis HW
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
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.
0 commentaires
Plus de réponses (0)
Voir également
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!