I've just started learning matlab and I am trying to solve this differential equation

조회 수: 1 (최근 30일)
I am new to MATLAB and I was trying to solve this differential equation and got the end result
syms y(x)
dy=diff(y);
ode= diff(y,x,2)+3*y==0;
cond1= y(0)==1;
cond2= dy(0)==0;
ysol(x)= dsolve(ode,cond1,cond2)
ysol(x) =
cos(3^(1/2)*x)
now if I want to solve y(1)=? in terms of y(1)=0.99 not cos(3^(1/2)) with 1 deg input argument. how should I do that? Thank you!

채택된 답변

Torsten
Torsten 2018년 8월 20일
Add the line
ysol(1)
at the end of your code.
  댓글 수: 3
Torsten
Torsten 2018년 8월 20일
편집: Torsten 2018년 8월 20일
cos(sqrt(3)) is not 0.99.
Or do you mean 1 deg instead of 1 rad as input argument ?
Use double(ysol(1)) or double(ysol(pi/180)) depending on whether you mean 1 rad or 1 deg.
Ankit Gupta
Ankit Gupta 2018년 8월 20일
편집: Ankit Gupta 2018년 8월 20일
I beg your pardon, sir! I mean 1 deg input argument. Thank You sir!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dimitris Kalogiros
Dimitris Kalogiros 2018년 8월 20일
you can access the value of y(1) by writting .... y(1)
syms y(x)
%dy=diff(y)
ode= diff(y,x,2)+3*y==0
cond1= y(0)==1
cond2= dy(0)==0
ysol(x)= dsolve(ode,cond1,cond2)
%--------------------------------
% just displaying value of y(1)
disp( ysol(1) )
  댓글 수: 1
Ankit Gupta
Ankit Gupta 2018년 8월 20일
편집: Ankit Gupta 2018년 8월 20일
Sir! I did that but I want Answer as 0.99. It is showing cos(3^(1/2)) with i deg input argument.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by