# [Tutor] Loops and matrices'

Emile van Sebille emile at fenx.com
Tue Aug 30 01:26:03 CEST 2011

```On 8/29/2011 3:28 PM Reed DA (Danny) at Aera said...
> Hi all,
>
> I have a matrix which contains temperatures. The columns are time,
> spaced 33 seconds apart, and the rows are depth intervals. What I'm
> trying to do is create another matrix that contains the rate of change
> of temperature for each depth. The array is called LS_JULY_11 and the
> output array should be delta_temp
>
> What I have so far is:-
>
> import numpy
>
> #determine the existing matrix size
>
> columnsize = LS_JULY_11.columnSize()
>
> matrixsize = LS_JULY_11.size()
>
> rowsize = matrixsize/columnsize
>
> #define time step
>
> TIME_STEP = 33
>
> #create matrix size of the same size
>
> delta_temp = numpy.zeros((rowsize,columnsize))
>
> #cycle through all indicies in temperature matrix
>
> for i in rowsize:
>
>                  for j in columnsize:
>
>                                  delta_temp(i,j) = (LS_JULY_11(i,j) -
> LS_JULY_11(i,j-1))/TIME_STEP
>
>                                  j = j+1
>
>                  i = i + 1
>
> the error I get is:-
>
>    File "<string>", line 18 (33)
>
> SyntaxError: can't assign to function call

delta_temp access and assignment likely wants to be expressed with
brackets rather than parens.

Emile

ActivePython 2.6.6.15 (ActiveState Software Inc.) based on
Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit
(Intel)] on win32
>>> spam(1,2)=6
File "<stdin>", line 1
SyntaxError: can't assign to function call
>>>

>
> Help would be greatly appreciated
>
> Thanks
>
> Danny
>

```