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/README.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
75 lines (46 sloc)
2.38 KB
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
# curve_fitting | |
Homework 5 | |
#Problem 1 | |
A least-squares function is created that accepts a Z-matrix and dependent variable y as input and returns the vector of best-fit constants, a, the best-fit function evaluated at each point, fx, and the coefficient of determniation, r2. | |
The following results of each variable are calculated for each case function: | |
a) y=0.3745+0.98644x+0.84564/x | |
| a | fx | r2 | | |
|---------|--------|--------| | |
| 0.3745 | 2.2066 | 0.9996 | | |
| 0.9864 | 2.7702 | | | |
| 0.8456 | 3.6157 | | | |
| | 4.5317 | | | |
| | 5.4758 | | | |
b) y=-11.4887+7.143817x-1.04121 x^2+0.046676 x^3 | |
| a | fx | r2 | | |
|---------|--------|--------| | |
|-11.4887 | 1.8321 | 0.8290 | | |
| 7.1438 | 3.4145 | | | |
| -1.0412 | 4.0347 | | | |
| 0.0467 | 2.9227 | | | |
| | 2.4947 | | | |
| | 3.2330 | | | |
| | 4.9595 | | | |
c) y=4.0046e^(-1.5x)+2.9213e^(-0.3x)+1.5647e^(-0.05x) | |
| a | fx | r2 | | |
|---------|--------|--------| | |
| 4.0046 | 5.9321 | 0.9971 | | |
| 2.9213 | 4.5461 | | | |
| 1.5647 | 3.2184 | | | |
| | 2.5789 | | | |
| | 2.1709 | | | |
| | 1.8726 | | | |
| | 1.6425 | | | |
| | 1.4605 | | | |
| | 1.1940 | | | |
#Problem 2 | |
For this problem, we look at the case where the independent variable is temperature and the dependent variable is failure (1=fail, 0=pass). A function called cost_logistic.m takes the vector a, independent variable x and dependent variable y so that the output is [J,grad] or [cost, gradient]. Also, we solved for a0 and a1 on part b and plotted the data in part c. | |
a) | |
[J, grad] = cost_logistic(a, x, y) | |
J = 115.5085 | |
grad = 5.0130 | |
b) The result for a0 and a1 generated through cost_logistic | |
c) The plot is located in the repository under Bestfitgraph.PNG | |
#Problem 3 | |
The function boussinesq_lookup.m is writtent so that when you enter a force , q, dimensions of rectangular area a, b, and depth, z, it uses a third-order polynomial interpolation of the four closest values of m to determine the stress in the vertical direction as shown in the file in the repository. | |
b) The boussinesq_lookup.m code is copied to a file called boussinesq_spline.m using a cubic spline to interpolate in two dimensions, both m and n, that returns sigma_z. | |