Permalink
Cannot retrieve contributors at this time
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?
curve_fitting/run_hw6.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (30 sloc)
629 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |