Skip to content
Permalink
048fa8e03f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
40 lines (30 sloc) 629 Bytes
clear
clc
run('problem_1_data.m')
%test the first data set
Z1=[xa.^0,xa,xa.^-1];
[a, fx, r2] = least_squares(Z1,ya)
%plots the data and the line of best fit
subplot(2,2,1)
plot(xa,ya,'o');
hold on
plot(xa,fx);
Z2=[xb.^0,xb,xb.^2,xb.^3];
hold off
%tests te second data set
[a, fx, r2] = least_squares(Z2,yb)
%plots the data and the line of best fit
subplot(2,2,2)
plot(xb,yb,'o');
hold on
plot(xb,fx);
hold off
%tests the third data set
Z3=[exp(-1.5*xc),exp(-.3*xc),exp(-.05*xc)];
%plots the data and the line of best fit
[a, fx, r2] = least_squares(Z3,yc)
subplot(2,2,3)
plot(xc,yc,'o');
hold on
plot(xc,fx);
hold off