Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Matlab code to work in Mathcad

Status
Not open for further replies.

bgtman9

Mechanical
Jul 30, 2009
7
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
 
Replies continue below

Recommended for you

You could RF this thread and repost in the Mathcad forum, as a start.

> 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
 
and it doens't run in matlab anyway.

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Yes, it will not because I didnt give the whole code, just the for loop i wanted to create. Thanks for your help though, I think I have figured it out.

Thanks,
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor