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

simple loops and operations with variables in Prime 4.0

SOLVED
Highlighted
Participant

simple loops and operations with variables in Prime 4.0

Hello to everybody.

To define loops in mathcad, any release of it, I use the simple statement "m=1,2..nmod", where in this case nmod is the maximum number of modes for an electromagnetic calculation.

Since my background was in fortran or similar languages, I initialized a variable "totcap:=0" and then I tried to increase this value calculating each time terms to be added with respect to the previously calculated one, updating the quantity "totcap", ending the loop with the statement "return m", being m the index that I defined.

Actually, but probably is my trivial error in using Prime, it seems that I mixed variables that cannot be summed...

Attached is the file. May you help me?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: simple loops and operations with variables in Prime 4.0

Programming commands like return may only be used inside a program block, not on worksheet level.

Its not necessary to define a range variable m. In a program a for-loop does the job:

Werner_E_0-1601423565488.png

 

View solution in original post

4 REPLIES 4
Highlighted

Re: simple loops and operations with variables in Prime 4.0

maybe I solved with the attached file, just using the sum function. Is it correct?

Highlighted

Re: simple loops and operations with variables in Prime 4.0

Yes, its correct and sure a very compact way to do the job (compared to the manual sum programming a sshown in my prior answer).

Highlighted

Re: simple loops and operations with variables in Prime 4.0

Thank you Werner. Actually, as my past experience is mainly on classical programming I tried to follow simple methods for simple questions.

Thanks, by the way, for the definition of "fF", as it is not defined by default.

Highlighted

Re: simple loops and operations with variables in Prime 4.0

Programming commands like return may only be used inside a program block, not on worksheet level.

Its not necessary to define a range variable m. In a program a for-loop does the job:

Werner_E_0-1601423565488.png

 

View solution in original post

Announcements