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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Undefined variable

40 REPLIES 40
MikeArmstrong
5-Regular Member
(To:KaiRussell)

Just so I am certain on what your trying to do, can you confirm the output you would expect from the attached image.

Mike

Mike,

Got that example wrong - thought I had checked it - sorry!

In the attached example#2, the factor should equal (C D), but because the E is undefined the program will not return an answer

Kai

MikeArmstrong
5-Regular Member
(To:KaiRussell)

Something like the attached.

Just add a symbolic evaluation.

Mike

That doesnt seem to work Mike - Mathcad could just be having a 'bad day'. I'll let you know

MikeArmstrong
5-Regular Member
(To:KaiRussell)

Try the attached worksheet.

Mike

Alternatively, you could set E:=NaN

Alan

RichardJ
19-Tanzanite
(To:KaiRussell)

Mike's symbolic calculation approach will work sometimes, but only if the symbolic solver can find a solution. That is far from guaranteed. Here's an old thread on the issue:

http://communities.ptc.com/message/128347#128347

They messed up the order of the posts when they transferred it from the Collaboratory, but not in a way that is too confusing

MikeArmstrong
5-Regular Member
(To:RichardJ)

Richard Jackson wrote:

Mike's symbolic calculation approach will work sometimes, but only if the symbolic solver can find a solution. That is far from guaranteed. Here's an old thread on the issue:

http://communities.ptc.com/message/128347#128347

They messed up the order of the posts when they transferred it from the Collaboratory, but not in a way that is too confusing

Richard,

The attached worksheet doesn't seem to work.

Mike

Which bit doesn't work? Do you see the matrix for the final evaluation of P?

MikeArmstrong
5-Regular Member
(To:RichardJ)

Richard Jackson wrote:

Which bit doesn't work? Do you see the matrix for the final evaluation of P?

Sorry Richard,

My Mathcad was having a funny turn.

Mike

This is a case where I would like to delete mine and associated posts.

>This is a case where I would like to delete mine and associated posts.<

__________________________

So, like me: all my messages only , not messages from others.

Dan hasn't even acknowledged this "facebook bug".

Simple matter of "markNaN" in what I delete,

then zap "NaN' from the data base , any kid can do that.

MikeArmstrong
5-Regular Member
(To:jeanGiraud)

jean Giraud wrote:

__________________________

So, like me: all my messages only , not messages from others.

Dan hasn't even acknowledged this "facebook bug".

Simple matter of "markNaN" in what I delete,

then zap "NaN' from the data base , any kid can do that.

I was actually thinking about removing my query about the worksheet not working and all corresponding posts, but after the fuss which has been kicked up recently (by myself), I think I'll leave the posts in.

Mike

This is a case where I would like to delete mine and associated posts.

What's it worth?

evil grin.gif

MikeArmstrong
5-Regular Member
(To:RichardJ)

What's it worth?

evil grin.gif

Sorry Richard,

I haven't anything to give.

Mike

MikeArmstrong
5-Regular Member
(To:RichardJ)

Richard Jackson wrote:

Which bit doesn't work? Do you see the matrix for the final evaluation of P?

Richard,

The final evaluation of P goes red when "three" is selected as the number of data arrays for n[r.

Mike

The final evaluation of P goes red when "three" is selected as the number of data arrays for n[r.

Sure, because the third array assignment is disabled. The error message is telling you that you can't stack the string "UNDEFINED" onto the other arrays. Enable the third assignment, and hit Ctrl F9 to recalculate the sheet (I only just noticed the Ctrl F9 is necessary, and I'm not sure why it should be).

MikeArmstrong
5-Regular Member
(To:RichardJ)

Richard Jackson wrote:

Sure, because the third array assignment is disabled. The error message is telling you that you can't stack the string "UNDEFINED" onto the other arrays. Enable the third assignment, and hit Ctrl F9 to recalculate the sheet (I only just noticed the Ctrl F9 is necessary, and I'm not sure why it should be).

Am i missing something hear (having a blond day). The original query was "whether there is any way of getting a workbook to calculate the programming sequence if one of the internal variables are undefined". If the third array assignment is disabled this is defeating the object isn't it.

He wanted to do it automatically...... I think.

Mike

Am i missing something hear (having a blond day).

Yes

In the example you can choose to stack two or three matrices. If you only choose to stack two of them you really shouldn't need to define the third one, because it's not going to be used. The problem is that you do need to define it though, because the "if" in the program refers to it. The redefinition using a scripted component is a workaround that allows the program to work for two matrices even if the third matrix is an undefined variable. If you choose to stack all three matrices, then clearly they all need to be defined.

MikeArmstrong
5-Regular Member
(To:RichardJ)

Richard Jackson wrote:

Am i missing something hear (having a blond day).

Yes

Right, got my head screwd on.

Have a look at the attached worksheet. I have used Richards worksheet to achieve what is required.

Richard - SORRY FOR DOUBTING!!!!!!

Mike

Cool. Hopefully that will work for Kal. As I already mentioned though, the variables that are redefined must be in the top level worksheet. The function will work for variables in a referenced worksheet, but not when the worksheet is first opened. You need to hit Ctrl F9 to get it to calculate correctly (I'm not sure why - a bug I think). There is a workaround for this problem though, using one more level of indirection. Note that a and f are now defined, because they are picking up on the built in units A and F. If this is a problem, then don't use variable names that overwrite built in units or constants!

Hi Rich,

That MathCAD worksheet does not seem to work for me. I enabled the Redefine equation, but there was no result from the bottom equation.

I unfortuneately prohibited from loading the workbook I'm working on.

The variables within the factor program come from several referenced MathCAD workbooks, and I'm guessing that's why the symbolic function won't work.

Cheers,K

RichardJ
19-Tanzanite
(To:KaiRussell)

That MathCAD worksheet does not seem to work for me. I enabled the Redefine equation, but there was no result from the bottom equation.

Do you mean for the worksheet I posted, or when applied to your worksheet?

The variables within the factor program come from several referenced MathCAD workbooks, and I'm guessing that's why the symbolic function won't work.

That will certainly stop my function based on a scripted component from working properly.

You could try this:

Late's say the variables defined in the referenced worksheet(s) are a1, a2, a3, etc. At the top of the main worksheet put A1:=a1, A2:=a2, A3:=a3, etc. Then see if any of these solutions work if you reference the variables A1, A2, A3, etc, rather than a1, a2, a3, etc.

Morning Rich,

The MathCAD worksheet you posted did not seem to be working - did you mean for me to try and apply to it mine?

If I provide all the inputs, the function works fine becauce all the variables have now been defined.

I am hoping to use the fuction when variables have been purposely left undefined. Have I misunderstood your question?

RichardJ
19-Tanzanite
(To:KaiRussell)

When you open the worksheet and scroll to the end this is what you should see:

redefined.gif

That's not what you see? Which version of Mathcad are you running (including service releases)?

Rich,

I can see all of that. I running V 15.

I will try and apply this to my template for each of the variables and see where we get to

Thanks,

K

RichardJ
19-Tanzanite
(To:KaiRussell)

OK, but bear in mind you can only use the function to refer to variables in the top level sheet, not in any referenced sheets.

MikeArmstrong
5-Regular Member
(To:KaiRussell)

Kai Russell wrote:

That MathCAD worksheet does not seem to work for me. I enabled the Redefine equation, but there was no result from the bottom equation.

I unfortuneately prohibited from loading the workbook I'm working on.

The variables within the factor program come from several referenced MathCAD workbooks, and I'm guessing that's why the symbolic function won't work.

You don't have to load the actual workbook your working on, just a example.

So the symbolic function I supplied just work as well as Richard's worksheet????

Mike

Hi Mike,

I tried a simple example (#2), but that's probably as much as I can give.

The work book is template for 5 different types of pressure vessel, and dependent on the type selected, the specific table is referenced.

The referenced workbooks pulls out rows and columns from an excel table depending on the inputs I have specified.

If I leave one of the selections blank, this is when I'll get an undefined varable which will bounce back into the factor program. So far, I have got round the problem by defining the specific inputs relevant to the assessment I'm doing.

I have been hoping that there'll be a way that I can get the function to wrk, without havng all the variables defined.

Does this clrify it at all?

MikeArmstrong
5-Regular Member
(To:KaiRussell)

Kai Russell wrote:

I have been hoping that there'll be a way that I can get the function to wrk, without havng all the variables defined.

Does this clrify it at all?

Kai,

I am clear on what your trying to achieve, that's why offered a solution in the second post within this thread.

We can only work with what you give us. I offered a solution to the first sheet you posted and as of yet haven't had it fail. I have tried a few different options (leaving different varibles blank) and always had the symbolic processor return an answer.

Mike

Top Tags