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

Odesolve Error: Variable is Undefined?

ptc-4847847
1-Newbie

Odesolve Error: Variable is Undefined?

Hello All, I am a chemical engineering student and a first time MathCAD user.

I am currently running MathCAD 2.0 Prime, and to be blunt, I have no clue what I am doing when it comes to solving a system of ODE. I have attached a worksheet with a problem that I am trying to solve for my Process course. I have reproduced a correct solution in a CAS that I am more familiar with, but have no dice with MathCAD 2.0 Prime. The odesolve function is spitting a "Variable is undefined, check that the label is set correctly" message at me. I haven't the slightest clue how to fix this error. Could a more briefed user please impart some knowledge onto me so I can learn how to solve a system of ODEs in Mathcad?

Thanks,

Alex Holburn

1 ACCEPTED SOLUTION

Accepted Solutions

The atttached should help.

Alan

View solution in original post

4 REPLIES 4

The atttached should help.

Alan

I owe you a beer, Mr. Stevens.

After seeing this and reworking it myself, I think I might like MathCAD better than MATLAB simply from a perspective of units analysis. It is a bit of a jump going from lines of code to WYSIWYG, but I'm liking it.

-Alex

Very big things I noticed from playing with the ordering of the worksheet that you fixed for me:

If I define an initial condition for odesolve on the same line or after the line the odesolve is used on, I'll get an error with respect to that variable. Always define the Initial Conditions before odesolve is used.


The next big one I learned was that I must always insert a solve block before using odesolve and presumably anything else in the solver ribbon.\

Functions can be defined in MathCAD in a similar manner as you would define one in C or MATLAB. What this translates to for the new person like me is that your functions should have this syntax at definition:

functionname(var1,var2,var3,...,varn):= some operation

and you call it in the same fashion you would one in C source or a mfile.

Alex Holburn wrote:

Functions can be defined in MathCAD in a similar manner as you would define one in C or MATLAB.

One difference between function definitions in Matlab and Mathcad is that in the former they need to be defined after the calling program (if they don't exist as seperate files) whereas in Mathcad they must be defined before they are called. Also Matlab syntax is different (input parameters are on the right hand side, output variables are on the left).

Mathcad's ability to use units is one of its great strengths, and is one of the (few) areas where Prime has improved on M15!

Alan

Top Tags