Skip to main content
1-Visitor
January 9, 2012
Solved

Error using Minimize inside a user defined function

  • January 9, 2012
  • 2 replies
  • 4830 views

Dear All,

I'm trying to use the Minimize function inside a used defined function and I'm getting the following error "The variable is undefined" but outside the function it works very well.

As you can see the function was get from the Examples from the mathcad help my problem is similar to the one on the attached file.

Thanks in advance,

Lourival

Best answer by ptc-4399411

Dear Valery,

Thank you for your suggestions I found it useful also I found another way to get around this. Discussing with a PTC support I got the followoing suggestion.

Error Resolved.png

Please let me know.

Thanks in advance,

2 replies

23-Emerald I
January 9, 2012

You cannot build a solve block inside a program.

1-Visitor
January 9, 2012

Dear Fred,

Thanks for your prompt answer, but I found it a little bit stranger because I already build a solve block inside a program, but was with the function Find, is it still fits the answer? Otherwise how could I get around this issue?

Thanks

23-Emerald I
January 9, 2012

You can create a function using a solve block:

Given

(P(T) := Find(x,y)

Then use P(T) inside a program.

If you have an example of a Given/Find solve block inside a program, please post it.

24-Ruby IV
January 9, 2012

We can use the Minimize/Maximize function without the Given keyword.

In a program too.

But see a very interesting error - 2 is a number not a variable:

MinimizeProgram.png

1-Visitor
January 10, 2012

Dear Valery,

Following your suggestion and Fred I defined the function like the figure belowSem título.png

As you can see the Minimize function is used outside the program and also I parametrize the function that I should use.

Also went a little bit deeper by parameterizing the constrains also, and this is my aim using the Minimize function. I would like to run a small program with a variation on the constrains minimizing for each case via For or While.

Any ideas?

ptc-43994111-VisitorAuthorAnswer
1-Visitor
January 12, 2012

Dear Valery,

Thank you for your suggestions I found it useful also I found another way to get around this. Discussing with a PTC support I got the followoing suggestion.

Error Resolved.png

Please let me know.

Thanks in advance,