Skip to main content
1-Visitor
April 9, 2013
Solved

Trouble programming a for statement

  • April 9, 2013
  • 2 replies
  • 4773 views

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.

Best answer by AndyWesterman

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

2 replies

17-Peridot
April 9, 2013

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

12-Amethyst
April 9, 2013

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

1-Visitor
April 9, 2013

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

I really really really appreciate your help.

This forum is awesome.

Saludos.