From 5ee46c638d1727d75996b9b8c8aa2bc0f19b2c4e Mon Sep 17 00:00:00 2001 From: Tommy Date: Thu, 5 Oct 2017 21:32:23 -0400 Subject: [PATCH] 4c 4c --- README.md | 13 +++++++++++++ sse_of_parabola.m | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 sse_of_parabola.m diff --git a/README.md b/README.md index 34a858e..6d8fd53 100644 --- a/README.md +++ b/README.md @@ -85,3 +85,16 @@ fx = 1.0e+04 ea = 8.6968e-05 iter = 27 ``` +c) +```matlab +function SSE = sse_of_parabola(K,xdata,ydata) + % calculate the sum of squares error for a parabola given a function, func, and xdata and ydata + % output is SSE=sum of squares error + K1=K(1); + K2=K(2); + y_function = K1*xdata+1/2*K2*xdata.^2; + SSE = sum((ydata-y_function).^2); +end +``` + +d) diff --git a/sse_of_parabola.m b/sse_of_parabola.m new file mode 100644 index 0000000..ace15b1 --- /dev/null +++ b/sse_of_parabola.m @@ -0,0 +1,8 @@ +function SSE = sse_of_parabola(K,xdata,ydata) + % calculate the sum of squares error for a parabola given a function, func, and xdata and ydata + % output is SSE=sum of squares error + K1=K(1); + K2=K(2); + y_function = K1*xdata+1/2*K2*xdata.^2; + SSE = sum((ydata-y_function).^2); +end