- #1
Pythagorean
Gold Member
- 4,403
- 314
I get different results from these two functions. I need a fresh pair of eyes to help me find the discrepancy. The old way I did it, with the for-loop, gave proper results (but is slower, I think).VECTORIZED (wrong):
vectorized result:
a4 = 0.5300
FOR-LOOP (right):
for-loop result:
a4 = 0.4572
Code:
Nss = .5*(1+tanh((y(1,:)-V3)/V4)); %N as t --> inf
tau = 1./(phi*cosh((y(1,:)-V3)./(2*V4)));
dy(:,2) = (Nss-y(2,:))./tau;
a4 = (Nss(1)-y(2,1))./tau(1);
save newodeset a4
vectorized result:
a4 = 0.5300
FOR-LOOP (right):
Code:
Nss = .5*(1+tanh((y(1)-V3)/V4)); %N as t --> inf
tau = 1/(phi*cosh((y(1)-V3)/(2*V4)));
dy(2) = (Nss-y(2))/tau;
a4 = a4 = (Nss-y(2))/tau;
a4 = 0.4572