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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Trouble programming a for statement

ptc-5016437
1-Visitor

Trouble programming a for statement

Hi everyone, I'm programming a simple "for" statement and for some reason It doesn't work, I don't know what is the problem because I've defined all the variables but mathcad says that one of them is undefined.

Clipboard01.jpg

I've attached the original file.

Thx in advance. And excuse me for my poor english, I'm Spanish.

ACCEPTED SOLUTION

Accepted Solutions

I've changed a few items to make the program operate, but there are assumptions that may not be valid.

1. Moved the break statement to the end of the for loop, you can keep it at the beginning but then you will need to initialise the N.c, N.as & N.ai variables & the result will be the same.

2. the return value is now just x.f. Mathcad 15,14 ... does not like to mix units in arrays & the program was failing for this.

You can deUnit the return values & then add them back outside the program .

You may be able to return values with units directly but I don't know how (or even if it is possible)

3. the for loop needs to be defined as start value, next value ... final value

4.value of c changed from 0.01 to 0.01 *1/m to give a unit balance - not sure if this is correct or not.

Capture.PNG

Regards

Andy

View solution in original post

11 REPLIES 11
Raiko
17-Peridot
(To:ptc-5016437)

Hello Maikel,

it appears as if your variable xf isn't defined and as a consequence all related variables fail. Correct this and it should work just fine.

Raiko

I've changed a few items to make the program operate, but there are assumptions that may not be valid.

1. Moved the break statement to the end of the for loop, you can keep it at the beginning but then you will need to initialise the N.c, N.as & N.ai variables & the result will be the same.

2. the return value is now just x.f. Mathcad 15,14 ... does not like to mix units in arrays & the program was failing for this.

You can deUnit the return values & then add them back outside the program .

You may be able to return values with units directly but I don't know how (or even if it is possible)

3. the for loop needs to be defined as start value, next value ... final value

4.value of c changed from 0.01 to 0.01 *1/m to give a unit balance - not sure if this is correct or not.

Capture.PNG

Regards

Andy

Thx a lot to everyone, specially to A Westerman, you were right.

I really really really appreciate your help.

This forum is awesome.

Saludos.

2. the return value is now just x.f. Mathcad 15,14 ... does not like to mix units in arrays & the program was failing for this.

You can deUnit the return values & then add them back outside the program .

You may be able to return values with units directly but I don't know how (or even if it is possible)

Hi again, may you tell me how can I deUnit the return values?

Regards.

All you can do is divide by the appropriate unit inside the program & the multiply by the same unit outside - not ideal , but best available.

Capture.PNG

Regards

Andy

Fantastic.

Thx again.

Regards

A Westerman wrote:

All you can do is divide by the appropriate unit inside the program & the multiply by the same unit outside - not ideal , but best available.

Capture.PNG

Regards

Andy

This problem is solved in Mathcad Prime:

abc.png

Unfortunately for me - 1 step forward , 3 steps back

A Westerman wrote:

Unfortunately for me - 1 step forward , 3 steps back

Point please your 3 steps back

Here http://communities.ptc.com/polls/1134

No scripted components

No 3D plots

No Hyperlinking

(For starters)

Regards

Andy

A Westerman wrote:

No scripted components

No 3D plots

No Hyperlinking

(For starters)

Regards

Andy

No scripted components - no viruses

No 3D plots in Mathcad 15 on Windows 8

No Hyperlinks more security

Etc

Announcements

Top Tags