Help Figure out the error

조회 수: 1 (최근 30일)
Joshua Amuga
Joshua Amuga 2016년 11월 2일
답변: Walter Roberson 2016년 11월 5일
IVP=ode({y''(x)+4*y'(x)+3*y,y(0)=3,y'(0)=4},y(x));
|
Error: Unbalanced or unexpected parenthesis or bracket.

답변 (2개)

Nick Counts
Nick Counts 2016년 11월 5일
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 2016년 11월 5일
You are trying to use MuPAD syntax inside of MATLAB.
dsolve('D2y-4*Dy+3*y','y(0)=3','Dy(0)=4')

태그

Community Treasure Hunt

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

Start Hunting!

Translated by