MATLAB Determine the best equationsfits for each of the foll
MATLAB- Determine the best equations/fits for each of the following data sets. Use cftool. In addition to listing the equations and the associated coefficients, take screenshots of each fit.
a) x=[10 12 15 17 20 22 25 27 30 32 35]; y=[.95 1.05 1.25 1.41 1.73 2 2.53 2.98 3.85 4.59 6.02];
b) x=[10 20 30 40 50 60 70 80]; y=[.51 .69 .92 1.21 1.33 1.61 1.76 2];
c) x=[310 320 325 330 335 340 345 350]; y=[516 526 535 587 640 715 857 1040];
Solution
A)
The dot operator signifies an element-by-element operation. The dot
can be used for multiplication
.
*
, division
./
, or exponentiation
.^
of
elements of vectors that are the same size. Omitting the dot before an
arithmetic operator means
MATLAB
performs the matrix version of the
operation.
•
On Line 21 we tried to perform a matrix multiplication of a 2
2 matrix
with a 1
4 matrix. This results in an error because you can only multiply
two matrices if the number of columns in the first equals the number of
rows in the second.
On Line 24 we get a similar error if we try to perform an element-by-element multiplication, as this does not make any sense for matrices of different sizes.
You can access individual elements, entire rows and columns, and subsets of matrices using the notation matrix_name(row,column). Listin demon-strates how to access elements in a matrix.
On Line 7 the
size
command returns the number of rows and columns
in the matrix.
•
On Lines 11, 15 and 19, when accessing an individual element in a matrix,
the first number after the round bracket refers to the row number (row
index), and second number refers to the column number (column index).
•
On Line 19 the colon operator is used to denote all of the columns, i.e.
all the columns in the third row are selected. The colon operator can also
be used as a row index to denote all rows.
•Line 23 demonstrates accessing a single element in the matrix w to change its value.
•On Line 29 a new matrix v is created as a sub-matrix of w
.•Finally, on Line 34 a new matrix z is created as a sub-matrix of w. Square brackets are used within the round brackets to enclose the list of row and column numbers.

