xinzhi Wei
xinzhi Wei

Reputation: 1

Can't solve ODE in matlab, strange plot occur

enter image description here I've checked my code, which I think is ok, but can't get the right plot as in the book here's my code:

clc,clear,close all
syms y(x) dy d2y
dy=diff(y,1)
d2y=diff(y,2)
y=dsolve((1-x)*diff(y,2)==sqrt(1+diff(y,1)^2)/5,y(0)==0,dy(0)==0)
fplot(y,[0,2],'r')

Upvotes: 0

Views: 38

Answers (1)

Sam Mousavi
Sam Mousavi

Reputation: 21

the output of y = dsolve is a vector with 2 equations as its elements. Also in the range of fplot these functions are complex. Since I don't know which results you are looking for, you can try and check these alternatives for your plot and have a look at the output:

fplot(real(y(1)),[0,2],'r')

fplot(abs(y(1)),[0,2],'r')

fplot(imag(y(1)),[0,2],'r')

Upvotes: 1

Related Questions