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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

"indexed assignment to a matrix element is not permitted in a solve block mathcad"

jgvinholi
4-Participant

"indexed assignment to a matrix element is not permitted in a solve block mathcad"

Hi, I've been trying to use some solve blocks inside a program. The solve blocks return matrixes with the solutions of the equations. I'm trying to get these results inside a program, but the error "indexed assignment to a matrix element is not permitted in a solve block mathcad" keeps showing. I don't really understand what it means. I've attached the file.

 

Edit: I haven't put any solve block inside the program, but instead tried to get outputs from outside solve blocks.

1 ACCEPTED SOLUTION

Accepted Solutions

The reason for the error message you get is, that you have erratically used a vector index for H1_2 in the Hi-gap solve block when assigning the guess value.

After you change that for a literal index the error is gone away, but you get a new unit mismatch error when calling Hi_iron.

Can it be that you forgot a factor S3 on the left side of the third equation?

View solution in original post

12 REPLIES 12
LucMeekes
23-Emerald III
(To:jgvinholi)

You cannot (in Mathcad or Prime) put a solve block into a program, but you can make the output of a solve block a function which you can use further.

 

Success!

Luc

jgvinholi
4-Participant
(To:LucMeekes)

I haven't tried to put a solve block inside a program. What I'm doing is calling functions that give outputs from other solve blocks. What I'm doing is exactly what you suggested. I've expressed Myself badly, sorry.

Thanks for the response.

LucMeekes
23-Emerald III
(To:jgvinholi)

Check your labels. The 'Hf' solve block (2nd iteration) tries to find 'Hf1[1' which is labelled as a constant (green) instead of variable (black).

 

Success!

Luc

 

The reason for the error message you get is, that you have erratically used a vector index for H1_2 in the Hi-gap solve block when assigning the guess value.

After you change that for a literal index the error is gone away, but you get a new unit mismatch error when calling Hi_iron.

Can it be that you forgot a factor S3 on the left side of the third equation?

jgvinholi
4-Participant
(To:Werner_E)

Thank you very much. I'll take a look closely tomorrow and will post here a feedback.

jgvinholi
4-Participant
(To:Werner_E)

These really were the problems! In my ingenuity, I'd perhaps never get to this conclusion. Thank you.

Hi,

In the last bit of programming for "ans" you have used an iteration of "i" from 0 to 50.

The index "i" is not used within the programming block?  Is this intentional?

Cheers

Terry


@terryhendicott wrote:

Hi,

In the last bit of programming for "ans" you have used an iteration of "i" from 0 to 50.

The index "i" is not used within the programming block?  Is this intentional?

Cheers

Terry


I guess this is just doing the iteration 50 times hoping for convergence.

 

I think that one single solve block can replace all the others and this loop a well:

Bild.png

jgvinholi
4-Participant
(To:Werner_E)

That's impressive! How does Mathcad gets Hf_1 to calculate Mu_f? I thought the only way I could solve this problem was through repetitions, as I had done. Does Mathcad "know" it is needed to make a iterative process and do it by itself? Thanks for the help.


@jgvinholi wrote:

That's impressive! How does Mathcad gets Hf_1 to calculate Mu_f? I thought the only way I could solve this problem was through repetitions, as I had done. Does Mathcad "know" it is needed to make a iterative process and do it by itself? Thanks for the help.


Yes, Mathcad "knows" that. Every numerical solve block uses a numeric iteration algorithm (something like Levenberg-Marquardt, Quasi-Newton, etc. - not sure what the algorithm in KNITRO used by prime is) to get its solutions. Also the solve blocks you implemented work that way.

I simply combined your two last solve blocks to let Mathcad play around with all seven variable and get a solution in one run.

Hope the factor S3 I added (as written in my first reply) to balance the units was the correct choice.

jgvinholi
4-Participant
(To:Werner_E)

Often, knowing how the tool you're using works makes a big difference. The S3 you added is absolutely correct. I had forgotten to add it.

Again I'd like to thank you for the help. Couldn't be more grateful of your response than I do.

As Werner_E said, I'm just hopping for convergence heheh. 

Top Tags