> why do i get two indices for tg?
Let's look at your data. Your code:
Bg = (ki*(Tf-Ts)) / (LWC*beta*v*LF + (Qa+Qk)-((Haw+LWC*beta*v*cw+X*eps)*(Tf-Ta)));
tg = (rho_r /(LWC*beta*v))*Bg ;
tg_index contains the indices of all values abs(t-tg) that are less than 0.001. Let's plot those values,
Here we can see that there are two values less than your threshold and they are at the expected indices returned by find().
> the first index t( 45633 ) is not giving the correct index but i still receive it.
The investigation above shows that both indices correctly find values less than 0.001. Were you trying to find the minimum value? If so, [~, tg_index] = min(abs(t-tg)).