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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Error using Minimize inside a user defined function

ptc-4399411
1-Newbie

Error using Minimize inside a user defined function

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

ACCEPTED SOLUTION

Accepted Solutions

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,

View solution in original post

10 REPLIES 10

You cannot build a solve block inside a program.

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

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.

Dear Fred you were right I made a confusion looking at my files the Find function I defined outside the program in order to test the calculation procedure and then I implemented it via root inside the program

Fred, I found a different solution to the problem of Minimization, please check the post let me know what you think about.

Regards

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

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?

Lourival Mendes wrote:

Any ideas?

You can use an user function for the minimum finding and with constrains.

One example one simple user function for the minimum finding without constrains:

http://communities.ptc.com/videos/1460

And no problem to insert constrains in this function.

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,

RichardJ
19-Tanzanite
(To:ptc-4399411)

This is the correct way to do it.

Announcements

Top Tags