Juggler_IN
Active Member
- Joined
- Nov 19, 2014
- Messages
- 358
- Office Version
- 2003 or older
- Platform
- Windows
I am unable to convert the logic of a MATLAB code to VBA.
Any input will be of help. The code is:
Any input will be of help. The code is:
Code:
t=0s=3.14
pi=3.14
coeff1 = 1/(2*pi);
coeff2 = 1/(2*s);
coeff3 = pi/s;
u = 0.5 - rand();
out = -u*s;
outNext = out - (coeff1*sin(coeff3*out) + coeff2*out + u) ./ ...
(coeff2*cos(coeff3*out)+coeff2);
indxs = find(abs(outNext - out)>tol);
outPrev = out(indxs);
while ~isempty(indxs)
outNext = outPrev - (coeff1*sin(coeff3*outPrev) + coeff2*outPrev + u(indxs)) ./ ...
(coeff2*cos(coeff3*outPrev)+coeff2);
l = (abs(outNext - outPrev)>tol);
out(indxs(~l)) = outNext(~l);
outPrev = outNext(l);
indxs = indxs(l);
end
out = t + out;