Help Figure out the error

1 view (last 30 days)
Joshua Amuga
Joshua Amuga on 2 Nov 2016
Answered: Walter Roberson on 5 Nov 2016
IVP=ode({y''(x)+4*y'(x)+3*y,y(0)=3,y'(0)=4},y(x));
|
Error: Unbalanced or unexpected parenthesis or bracket.

Answers (2)

Nick Counts
Nick Counts on 5 Nov 2016
Joshua,
Looks like there's a lot going on here.
It appears that ode() is a function and you are attempting to pass two arguments. The first argument is enclosed in {} which, in Matlab-land, defines a cell (variable type).
You are attempting to assign the following as the contents of a cell: y''(x)+4*y'(x)+3*y,y(0)=3,y'(0)=4
Data Types:
This is very confusing to poor Matlab (and others as well!) You can assign all kinds of variable types to the contents of a cell: numerical, string, objects, other cells... but you can't mix types within a cell.
Understanding the Error:
Matlab is trying to intemperate your code something like this:
"This cell contains the value of y, an empty string, possibly an index to something I don't understand or maybe just the value of x, maybe the string "(x)+4*y"... and so on.
Hopefully that makes sense.
Symbolic Math and Matlab
If you are trying to use Matlab's symbolic math capabilities, I suggest starting here:
Or possibly:
help syms
doc syms
Good luck!

Walter Roberson
Walter Roberson on 5 Nov 2016
You are trying to use MuPAD syntax inside of MATLAB.
dsolve('D2y-4*Dy+3*y','y(0)=3','Dy(0)=4')

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!