cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate code from Matlab to Mathcad "iter"

Ermis76
1-Newbie

Translate code from Matlab to Mathcad "iter"

Hello!

I have a matlab script, se part of it below. I'm new to both Matlab and Mathcad and programming in general.

My question is how does "iter" work in Matlab, is it just an another variable or does it actually perform some calculations? If not, can the code below be translated to Mathcad to perform some kind of iteration?

I hope this question makes sense.

%Iteration parameters

R=[];IT=[];mx=5800;deps=2;ini=2;i=1;vxy=0;

while vxy <= 1.001*txy

%STEP 2

%Estimate average strain in the studied element

e1=(i*deps+ini)*10^-6;

%STEP 3

%Uppskatta spricklutning

v=v;

%Estimate reinforcement stress in the y-direction

fsy=0.7*e1*Es;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

i=i+1; iter=0;fsxcr=0; fsycr=fyy*1.1;

delta_e=0;

while (fsxcr >= fyy | fsycr >= fyy) & iter < mx

iter=iter+1;

1 ACCEPTED SOLUTION

Accepted Solutions

iter is just a variable which starts at 0 ( iter=0) and increments by 1 every time through the "while" loop - this happens as long as the condition (fsxcr >= fyy | fsycr >= fyy) & iter < mx is true. Something similar could be written in Mathcad (with some changes of notation here and there).

Alan

View solution in original post

3 REPLIES 3

iter is just a variable which starts at 0 ( iter=0) and increments by 1 every time through the "while" loop - this happens as long as the condition (fsxcr >= fyy | fsycr >= fyy) & iter < mx is true. Something similar could be written in Mathcad (with some changes of notation here and there).

Alan

IRstuff
3-Visitor
(To:Ermis76)

There does not appear to be anything in the code that requires anything more complicated than a Mathcad indexed variable, putting the calculations in a function and calling the function with the indexed variable.

TTFN

This looks like it's a rather simplistic approximation to a differential equation that should be 'programmed' directly as that differential equation. Let mathcad do the real solving. (unless of course this is a homework / course excercise to learn about the errors in hand coded approximations 😉

Top Tags