matlab code to solve absolute error

조회 수: 3 (최근 30일)
John Gebre
John Gebre 2015년 6월 7일
답변: Image Analyst 2015년 6월 7일
I tried to solve the summation of absolute error by entering the following code in Matlab program. However, it display an error. So, is there anyone who can help me to edit or correct this one, sending other support link or code.
Function S=sum(a)
Xi=[Xi,....Xn]'
Yi=[Yi,...Yn]'
f(x)= ao+a1x
S=0
For i=1:n
S=S+abs(f(Xi)-Yi)
end
S
Thanks in advance.
  댓글 수: 1
John Gebre
John Gebre 2015년 6월 7일
편집: John Gebre 2015년 6월 7일
Hi there, I am looking your support on the above posted Matlab code.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2015년 6월 7일
Tons of problems with this. Misspelling of function as "Function" (MATLAB is case sensitive). Improper assignment of Xi and Yi (recursive, and no value had been set for Xn. Equation for f(x) is wrong in multiple ways. Used built in function, sum(), for the name of your own custom function. In the for loop, the sum doesn't match what you've asked in your prior two questions on the same formula. Misspelled "for" as "For". No indexing of Xi and Yi in the loop (like, it's not Xi(i) and Yi(i)). And so on. Why don't you just look at my answer to your two prior postings of this question - this one just made it worse.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by