Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

mathcad: hot to create cycle from equations

Status
Not open for further replies.

figord

Structural
Jun 5, 2012
3
Hi everybody!

I have a question: I wrote a worksheet with many many equations and variables, defined with ":="

Now, I need to trasform the simple calculation in a cycle, in order to repeat the calculation with many iput data; the problem is that variables have to be defined "locally" for the cycle, with the "left arrow".

I wonder if tere is a simple and quick way to chanche the definition of the variables (they are quite a lot) from "general" :)=) to local (<-). I wouldn't like to redefine all variables :).

I am a new user of mathcad, so I apologize if I post a stupid question.

Hope for an answer.
 
Replies continue below

Recommended for you

?? You create a function and call the function once for each of your inputs.

TTFN
faq731-376
7ofakss
 
Do you have a worksheet you can post so we can get a better idea of what's going on?

Are you trying to create a if/then sort of statement? or a function of a function sort of thing?

Programming statements in MathCAD take a bit more practice, but the tutorials are pretty straightforward. It's like a really ugly version of C++.

g(x), f(x) and f(g(x)) work in mathcad pretty easy... there's some order to the definition of the statements that's pretty strict, but nothing that can't be solved by banging your head against it.
 
Hi,

thanks for your answering. Unfortunately now I can't post the worksheet, but I think the easiest way is to trasform the equations I wrote in a function, and then giving everytime the new data.

What I was trying to do was to transform a simple set of equations in a "for" cicle, so that I could import "n" rows of data, and perform the calculation "n" times with the data of each row.

Eg:

Simple set:

------------------
x:= 1
y:= 2
z:= 3

f:= x + y

g:= f + z
--------------------


cicle:


---------------------
n11 n12 n13
N:= n21 n22 n23 so that ni1 = x; ni2 = y; ni3 = z
n31 n32 n33

for i:1,3

f[i := ni1 + ni2

g[i := f[i + ni3

end for

---------------------
Now, reading you advices, I think the best way is to trasform the set in a funcion of x,y,z, and specifing x,y,z each time.

Thanks for answering

 
Have you considered using a range variable instead to iterate over the variables?

i:=1..5

fi:= Ni,1 + Ni,2
gi:= fi + Ni,3

(I'd probably re-write it to use functions because that's my natural tendency, but range variables can be useful and easier for others to follow)
 
I have tried to do it, but the division is a problem because I need a scalar value....
 
In what context is division a problem? Can you post an example of the kind of expression that prevents you using range variables?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor