06.09.2021 Views

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 5. APPROXIMATION THEORY 192<br />

19.8<br />

19.1<br />

27.1<br />

31.0<br />

27.0<br />

22.7<br />

The next step is to store the part of the data we need as an array. The function<br />

select takes two arguments: the name of the table, and the column head<strong>in</strong>g the contents<br />

of which will be stored as an array. In our table there is only one column named Temp.<br />

In [4]: temp=select(data, :Temp);<br />

Let’s check the type of temp, its first entry, and its length:<br />

In [5]: typeof(temp)<br />

Out[5]: Array{Float64,1}<br />

In [6]: temp[1]<br />

Out[6]: 28.7<br />

In [7]: length(temp)<br />

Out[7]: 1056<br />

There are 1,056 temperature values. The x-coord<strong>in</strong>ates are the days, numbered<br />

t =1, 2, ..., 1056. Here is the array that stores these time values:<br />

In [8]: time=[i for i=1:1056];<br />

Next we def<strong>in</strong>e the matrix A, tak<strong>in</strong>g advantage of the fact the matrix is symmetric.<br />

The function sum(x) adds the entries of the array x.<br />

In [9]: A=zeros(4,4);<br />

A[1,1]=1056<br />

A[1,2]=sum(time)<br />

A[1,3]=sum(t->s<strong>in</strong>(2*pi*t/365),time)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!