Programming Snafu's - My Numerical Analysis HW
조회 수: 7 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matt Fig
2011년 2월 3일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!