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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Ordinary Differential Equations variable undefined

andreas_lanter
4-Participant

Ordinary Differential Equations variable undefined

Hello

I do not have a lot of experience with mathcad. Please help me!
I have to solve and ode which includes some equations. Now I can not calculate it because it says variabe undefined.
Why that?

ODE.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

OK, after a further look at your sheet I realized, that my advice of turning all functions into functions of t wasn't a good one. It should have worked (but for some reason it doesn't) but it sure was unnecessary.
The only advice which is to follow is to put the functions outside of the solve block (so you can also use them after the solve block).

I edited your last sheet (is attached) accordingly and now it works as supposed. Sorry for the confusion.

Werner_E_0-1585570486075.png

Werner_E_0-1585571133233.png

 

 

EDIT: Yes, I speak German, I'm Austrian.

 

View solution in original post

15 REPLIES 15

Hi

Attach your worksheet, or at least a worksheet that shows the problem you have. NOT just a picture.   Look below the Body text entry block and above the post button.  You can see a section where you can drag/drop or browse to add files.

 

You have not defined the function z2(t)  so Prime protests.

 

Cheers

Terry

 

 

Hi Terry

Thanks for helping

Attached the worksheet. I already figured out that it works if i define my equations as function from x2 and z2 and only the ode as function from x2 z2 and t.
Is this correct?
But now I want also plot for example Sz and Sx but i do not know how.
Maybe the whole approach is wrong.
Cheers

Andreas

I've only got Express, so I had to work around the ODE solve blocks.  

 

Attached Prime 6 Express.

Hi
Thanks a lot for your help.
Looks not that easy for me. I am not a mathematician.
You did not use any function to solve the ode? You defined the time step and solved it. Right?
Is there no other option to solve such equations?
Could you explain a bit more the yellow box? What did you there?
Express solve block.PNG

 

Any help is much appreciated! Thanks a lot!
Andreas

You did not use any function to solve the ode? You defined the time step and solved it. Right?

Express is Prime with a lot of things prevented from working. One of those "premium features" is the solve block, so I can't use the built-in ODE solvers like you did.  Since this is an initial value problem, we can use this method. 

Is there no other option to solve such equations?

Sure, the solve block (like you did.)  Works fine in regular Prime, but in Express, as soon as I recalculate, it's broken.  I can only view the file before I change anything.

Could you explain a bit more the yellow box? What did you there?

The yellow box (it's only highlighted,)is a construct from very early Mathcad.  It forces each equation in the block to be solved for a value of the index (j) before the index is incremented.  You could write each line out separately, but they would fail because they need to be evaluated together all at once.  (Try it!)These are simply your ODE's written as incremental files.

 

I think your original file was working, wasn't it?

Thanks for your help.
My file works in general but I have to problem that i can only plot x2 and z2.

I defined my equations as function from x2 and z2 and only the ode as function from x2 z2 and t.
But now I want also plot for example Sz and Sx but because I had to define them as function from x2 and z2 I can not plot them.

Maybe it is not possible with the solve block and odesolve but I am not sure.
I think would be much easier for me to use this solve blocks.
Regards

Andreas

ODE1.1.PNG

ODE1.2.PNG

You should move all function definitions outside of the solve block as all those functions are just used in the solve block but are not the ODEs.

Additionally you should also make "t" an argument of all those functions and in your calculations you have to use those functions as functions and not like simple variables.
That way you can use them after the solve block, too.

I haven't done it all the way but here is a small example what's to do:

Werner_E_0-1585563818344.png

You may redefine Sx(t):=Sx(x(t),y(t),t) after the solve block for simplicity.

Hi Werner
Thanks a lot for your help. I did it like you said but now mathcad says in the solve block "this value must be a function".
Can you open my file and have a look?
Thanks a lot for your help!!!!!!!!!!!
Andreas

Its strange as when I open your file, I get an "unknown" error.

Werner_E_0-1585569810849.png

Can you backtrace the error to see where it stems from?

Calculation ribbon

Werner_E_1-1585569910811.png

 

 

Hi Werner
Do you speak German?
I can not backtrace it.
Do I have to define another function in the odesolve?
I am not sure If my definition is correct.
Thanks for helping!

 

OK, after a further look at your sheet I realized, that my advice of turning all functions into functions of t wasn't a good one. It should have worked (but for some reason it doesn't) but it sure was unnecessary.
The only advice which is to follow is to put the functions outside of the solve block (so you can also use them after the solve block).

I edited your last sheet (is attached) accordingly and now it works as supposed. Sorry for the confusion.

Werner_E_0-1585570486075.png

Werner_E_0-1585571133233.png

 

 

EDIT: Yes, I speak German, I'm Austrian.

 

Truly interesting!

I just looked at this post (where I have no posts showing) and recognized it; I worked on this yesterday.

Capture.JPGCapture1.JPG

(I even got a kudo from Luc!)

I'm glad Werner was able to demonstrate how to do this in solve blocks, I was constrained to Express . . .

Hi Terry, Fred and Werner

 

Thanks a lot for all your help!
You safed me a lot of time reading books and looking videos from mathcad to solve this problem.
I just started using mathcad and also using this community.
I am surprised how fast I got a lot of help from you. Thanks again.
Looking forward getting more familiar with mathcad and I guess I will need more help in the future 😉
By the way. Does somebody know good literature etc. to learn mathcad?
Best regards
Andreas

 

Hallo Werner

 

Vielen Dank für deine Hilfe! Ich hab noch wenig Erfahrung mit Mathcad.
Arbeitest du viel damit und bist du viel in dieser community.
Wo wohnst du in Österreich? Ich bin aus der Ostschweiz.
Lieber Gruss
Andreas

 


@andreas_lanter wrote:

Hallo Werner

 

Vielen Dank für deine Hilfe! Ich hab noch wenig Erfahrung mit Mathcad.
Arbeitest du viel damit und bist du viel in dieser community.
Wo wohnst du in Österreich? Ich bin aus der Ostschweiz.
Lieber Gruss
Andreas


Ja, ich bin hier im Forum recht regelmäßig und habe doch ein gerüttelt Maß an Erfahrung mit dem Programm. Ich arbeite allerdings mit Mathcad 15 und nicht mit Prime, weil diese Neuentwicklung von PTC im Funktionsumfang, im Handling und in der Geschwindigkeit weit hinter MC15 bleibt. Die "Entwicklung" von Mathcad/Prime, seit PTC MATHCAD vor über 10 Jahren von Mathsoft übernommen hat, ist ein einziges Trauerspiel. Aber darüber wurde und wird hier im Forum ohnedies oft genug gejammert.
Und obwohl ich das Programm förmlich liebe, könnte ich es derzeit kaum guten Gewissens einem Ingenieur, der auf der Suche nach einem guten Allround-Tool ist, empfehlen.
Wenn man aber so wie du neu auf das Programm stößt und die ältere Version nicht kennt, sieht man das Ganze vielleicht gar nicht so negativ.
Also viel Erfolg mit Prime und schöne Grüße aus Wien
Werner

Top Tags