Converting Matlab code to work in Mathcad
Converting Matlab code to work in Mathcad
(OP)
I just cannot seem to write a mathcad program that is the same as a matlab program i wrote awhile back. The short script in MatLab is as follows:
G(1) = 0;
a_counter = .0000001;
H = F;
T(1) = 0;
T(2) = 0;
for j = 2:1:101
F(j) = F(j)-H(j-1);
T(j) = (2*F(j)/Hinc)-a_counter;
if T(j) > 2*G(j-1)
G(j) = T(j)/2;
else
G(j) = G(j-1)+0.001;
end
a_counter = T(j);
end
Any help would be greatly appreciated!
Thanks,
Tom
G(1) = 0;
a_counter = .0000001;
H = F;
T(1) = 0;
T(2) = 0;
for j = 2:1:101
F(j) = F(j)-H(j-1);
T(j) = (2*F(j)/Hinc)-a_counter;
if T(j) > 2*G(j-1)
G(j) = T(j)/2;
else
G(j) = G(j-1)+0.001;
end
a_counter = T(j);
end
Any help would be greatly appreciated!
Thanks,
Tom





RE: Converting Matlab code to work in Mathcad
> Mathcad, in general is not a programming environment, unlike Matlab. As such, it's usually not possible to get the same form.
> Mathcad generally uses indexed variables directly, so FOR loops are often unnecessary.
TTFN
FAQ731-376: Eng-Tips.com Forum Policies
RE: Converting Matlab code to work in Mathcad
Cheers
Greg Locock
SIG:Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.
RE: Converting Matlab code to work in Mathcad
Thanks,
Tom