×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# while cycle with functions

## while cycle with functions

(OP)
Hi, i would like to do a while cycle with functions inside. i have tried but seems that mathcad dont like functions inside.
what i want to do is augment a matrix i times like this:

#### CODE

A(x)=|  f(x)  0   |    <- this is a matrix with a function
|  0    f(x) |

i want my while cycle to augment N(x) matrix with A(x) to result in this:

#### CODE

N(x)=|  f(x)  0     f(x)   0 ... |
|  0    f(x)    0     f(x)..|
so the cycle i have made is:

#### CODE

A(x):= | f(x)    0  |
|  0     f(x)|
i:=0
N(x):= while i<3
A(x) <- augment(A(x),N(x))
i:=i+1

N(x)-> doenst calculate. it takes lot of time and nothin
thanks
Replies continue below

### RE: while cycle with functions

I would remove the recursive call.  That is why your computer hangs up.

#### CODE

A(x):= | f(x)    0  |
|  0     f(x)|
i:=0
N(x):= while i<3
vvv  Recursive call
A(x) <- augment(A(x),N(x))
i:=i+1
I didn't think you could increment a global variable "i" from inside the subroutine.  Just local variables.

### RE: while cycle with functions

(OP)
but i need that call N(x) to augment the matrix.
that means that i want to enlarge matrix A(x) with N(x) from the left to the right.
If i remove N(x) i cant augment the matrix.

i can do it manually, with no while cycle and i can do it too with a while cycle without functions. if i use constants instead of functions that routine works.

about the increasing variable i, i have it inside the routine, that is a mistake.

Thanks anyway :)

### RE: while cycle with functions

try this program

|i<-0 ->
|M<-N(x)
|while i<3
| |i<-1+1
| |M<-augment(A(x),M)

### RE: while cycle with functions

I think you will need to use the symbolic capability if you want to grow the functional form.

I'm sure it can be done. there are some examples such as Tom Gutman's Hessian, Ravel, etc. utilities on the http://collab.mathsoft.com/~Mathcad2000 forum.

The live symbolic can be called within a programme!

Philip

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!