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

Trouble programming a for statement

SOLVED
Newbie

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.

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Trouble programming a for statement

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

11 REPLIES 11

Re: Trouble programming a for statement

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

Re: Trouble programming a for statement

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

Re: Trouble programming a for statement

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

I really really really appreciate your help.

This forum is awesome.

Saludos.

Highlighted

Re: Trouble programming a for statement

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.

Re: Trouble programming a for statement

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

Re: Trouble programming a for statement

Fantastic.

Thx again.

Regards

Re: Trouble programming a for statement

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

Re: Trouble programming a for statement

Unfortunately for me - 1 step forward , 3 steps back

Re: Trouble programming a for statement

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