Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

while cycle with functions

Status
Not open for further replies.

crashkeeper

Structural
Joined
Feb 12, 2008
Messages
8
Location
PT
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
Can you please help me in this problem?
thanks
 
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.


 
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 :)


 
try this program

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

see the following image:

(german "erweitern" = engl. "augment")

Forum_engtips_Matrix.gif

The MathCAD sheet is avaible at:


Christian
 
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 forum.

The live symbolic can be called within a programme!

Philip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top