From: Pawel on 25 Jun 2010 06:20 I have got following code: y=dsolve('Dy=y*(1-y/5)','y(0)=6','x'); solution=inline(vectorize(y),'x'); x=0:0.01:10; plot(x,solution(x)); It is the logistic equation which is plotted well. However If I change the code to: y=dsolve('Dy=y*(1-y/5)+sin(x)','y(0)=6','x'); solution=inline(vectorize(y),'x'); x=0:0.01:10; plot(x,solution(x)); I got an error saying: ??? Error using ==> inlineeval at 15 Error in inline expression ==> matrix([]) Undefined function or method 'matrix' for input arguments of type 'double'. Error in ==> inline.subsref at 27 INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr); Please, help me sort it out :) Thank you in advance for hour help and time . Pawel
From: Steven Lord on 25 Jun 2010 09:46 "Pawel " <pc504(a)live.mdx.ac.uk> wrote in message news:i01vss$h2a$1(a)fred.mathworks.com... >I have got following code: > > y=dsolve('Dy=y*(1-y/5)','y(0)=6','x'); > solution=inline(vectorize(y),'x'); Don't do this. Just use SUBS to substitute in values to obtain results you can PLOT, or EZPLOT the symbolic solution. > x=0:0.01:10; > plot(x,solution(x)); > > It is the logistic equation which is plotted well. However If I change the > code to: > > y=dsolve('Dy=y*(1-y/5)+sin(x)','y(0)=6','x'); When you execute this line, you should see a warning that indicates that MATLAB could not find an explicit solution. Therefore evaluating the (empty) solution will not work. Instead, solve the ODE numerically using ODE45 or one of the other numeric ODE solvers. *snip* -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: Using light on specific object Next: Equations of Motion |