I have written the following code in MATLAB, trying to compute $\{f_{ij}\}_{i,j=1}^2 = -2e^{i+j-t}$ for different values of $t$.
for t=0.1:0.1:1
for i=1:2
for j=1:2
fij(i,j)= -2*exp(i+j-t);
end
end
end
I know after running this, I am supposed to get $f_{11} = -2e^{1.9} \approx 13.37$, but instead, I am getting $$ f_{ij} \approx \begin{bmatrix} -5.4366 & -14.7781 \\ -14.7781 & -40.1711 \end{bmatrix} $$
Could you please help me understand the problem?
The problem is, your code is repeatedly generating $f_{ij}(t)$ for different values of $t$ in $\{0.1,0.2,\ldots, 1\}$, and each consecutive calculation over-writes the one before, so you end up with the final value of $f_{ij}(1)$.
If you just want to get the values for one value of $t$:
If you want them all, you can use for k=1:10 t = k0.1 for i=1:2 for j=1:2 fij(k,i,j)= -2exp(i+j-t); end end end
Then,
f(1,:,:)will be $f_{ij}(0.1)$ andf(10,:,:)will be $f_{ij}(1)$.