ENGR 0011 Study Guide - Approximation Error

63 views6 pages
23 Sep 2013
School
Department
Course
Professor

Document Summary

%calculate the errors of different type plot if a==1. %use polyfit and polyval command to find the best fit coeff=polyfit(x,y,1); yline=polyval(coeff,x); %filter the date to find the rel error p=1; for i=1:length(x) if y(i)~=0 relative_error(p)=abs((y(i)-yline(i))/y(i)); p=p+1; end end. Sst=sum((y-sum(y)/length(y)). ^2); r2=1-sse/sst; gtext(["r^2=",num2str(r2)]) disp(["r^2=",num2str(r2)]) minabs=absolute_error(1); maxabs=absolute_error(1); minrel=relative_error(1); maxrel=relative_error(1); minloc=1; maxloc=1; relminloc=1; relmaxloc=1; %using polyfit and polyval to find the best fit coeff=polyfit(x,y,b); yline=polyval(coeff,x); %filter data to find the rel error p=1; for i=1:length(x) if y(i)~=0 relative_error(p)=abs((y(i)-yline(i))/y(i)); p=p+1; end end. %filt data and finf the ln(y) n=length(x); j=1; for i=1:n if y(i)>0 xfilt(j)=x(i); yfilt(j)=log(y(i)); j=j+1; end end sumxfilt=sum(xfilt); sumyfilt=sum(yfilt); sumxfilt2=sum(xfilt. ^2); sumxfiltyfilt=sum(xfilt. %filter data and find rel error p=1; for i=1:length(xfilt) if y(i)~=0 relative_error(p)=abs((y(i)-yline(i))/y(i)); p=p+1; end end. %filter data and find ln(x) and ln(y) n=length(x); j=1; for i=1:n if y(i)>0 && x(i)>0 xfilt(j)=log(x(i)); yfilt(j)=log(y(i)); j=j+1; end end sumxfilt=sum(xfilt); sumyfilt=sum(yfilt); sumxfilt2=sum(xfilt. ^2); sumxfiltyfilt=sum(xfilt. %filter data and find the rel error p=1; for i=1:length(xfilt) if y(i)~=0 relative_error(p)=abs((y(i)-yline(i))/y(i)); p=p+1; end end.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents