Question
Matlab Coding: I'm writting code that takes an input called data which is a two column matrix, with resistance values in the first column and
Matlab Coding:
I'm writting code that takes an input called data which is a two column matrix, with resistance values in the first column and temperature values in the second column. The function then uses the general least squares approach to determine the best values of a,b, and c for the model and returns the coefficents, a, b, and c in a row vector, the coefficient of determination and the standard error of the fit. below is the equation
My code works for everything except the standard error which is the last line of code, please help me fix the standard error line of code. Below is my code:
function [coeff, r_squared, standard_error] = student_solution(data) %General Linear Least-Squares with Left Division T = data(:,2); R = data(:,1); y = 1./T;
%Basis functions Z0 = ones(length(R),1); Z1 = @(x) log(R); Z2 = @(x) (log(R)).^3;
% Calculate Z matrix Z = [Z0,Z1(R),Z2(R)];
%Solve for coefficients A = Z\y; A1=A(1);A2=A(2);A3=A(3); coeff = [A1,A2,A3]
T_model=@(R) 1./(A1+(A2.*log(R))+(A3.*((log(R)).^3))); figure(1) plot(T,R,'rd') hold on
Rplot = linspace(min(R),max(R),100);
yplot = (A1*Z0)+(A2*Z1(Rplot))+(A3*Z2(Rplot));
Tplot = yplot./Rplot; plot(Rplot,Tplot,'b-') legend('data','model') hold off St = sum((T-mean(T)).^2); Sr = sum((T-T_model(R)).^2); r2 = 1-Sr/St; r_squared = r2 standard_error = std(coeff) / sqrt(length(coeff)) end
T = a + b In(R) + c (In (R)3 T = a + b In(R) + c (In (R)3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started