Get Help

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Ordinary Differential Equations variable undefined

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
05:08 AM

03-29-2020
05:08 AM

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?

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
08:16 AM

03-30-2020
08:16 AM

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.

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

15 REPLIES 15

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
07:10 AM

03-29-2020
07:10 AM

Re: Ordinary Differential Equations variable undefined

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
10:12 AM

03-29-2020
10:12 AM

Re: Ordinary Differential Equations variable undefined

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
12:40 PM

03-29-2020
12:40 PM

Re: Ordinary Differential Equations variable undefined

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

Attached Prime 6 Express.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
01:29 PM

03-29-2020
01:29 PM

Re: Ordinary Differential Equations variable undefined

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?

Any help is much appreciated! Thanks a lot!

Andreas

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
01:57 PM

03-29-2020
01:57 PM

Re: Ordinary Differential Equations variable undefined

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?**

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-29-2020
03:38 PM

03-29-2020
03:38 PM

Re: Ordinary Differential Equations variable undefined

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
06:14 AM

03-30-2020
06:14 AM

Re: Ordinary Differential Equations variable undefined

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:

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
07:14 AM

03-30-2020
07:14 AM

Re: Ordinary Differential Equations variable undefined

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
08:05 AM

03-30-2020
08:05 AM

Re: Ordinary Differential Equations variable undefined

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

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

Calculation ribbon

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
08:15 AM

03-30-2020
08:15 AM

Re: Ordinary Differential Equations variable undefined

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!

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
08:16 AM

03-30-2020
08:16 AM

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.

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
08:47 AM

03-30-2020
08:47 AM

Re: Ordinary Differential Equations variable undefined

Truly interesting!

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

(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 . . .

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
09:00 AM

03-30-2020
09:00 AM

Re: Ordinary Differential Equations variable undefined

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
09:02 AM

03-30-2020
09:02 AM

Re: Ordinary Differential Equations variable undefined

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-30-2020
09:41 AM

03-30-2020
09:41 AM

Re: Ordinary Differential Equations variable undefined

@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