How can I get the analytical solution for this problem?
조회 수: 42 (최근 30일)
이전 댓글 표시
I'm new to MATLAB, and was asked to get the analytical soltuion for the following function: , however, I'm having a really hard time.
My code was as follows, and I kept recieving an error when I tried to plot:
syms y(x);
ode = diff(y,x) == 2-sqrt(2*x-y+3);
cond = y(0) == 100;
ySol(x) = dsolve(ode,cond);
x = 0:1:100;
plot (x,ySol(x))
In all honestly, I'm not sure if this is the correct method to solving for an analytical soltuion. I would really appreciate any help, and if possible, any guidance on what other resources can help me become more proficient with MATLAB.
댓글 수: 0
채택된 답변
Walter Roberson
2020년 6월 14일
syms y(x);
ode = diff(y,x) == 2-sqrt(2*x-y+3);
cond = y(0) == 100;
ySol(x) = dsolve(ode,cond);
x = 0:1:100;
ySols = ySol(x);
subplot(1,2,1);
plot(x, real(ySols{1}), 'b', x, imag(ySols{1}), 'r');
legend({'real', 'imaginary'})
title('solution 1')
subplot(1,2,2)
plot(x, real(ySols{2}), 'b', x, imag(ySols{2}), 'r');
legend({'real', 'imaginary'})
title('solution 2')
댓글 수: 2
Walter Roberson
2020년 6월 14일
I ran the code and saw that executing ySol(x) returned a cell array with two entries, each one a 1 x 100 array of symbols.
추가 답변 (1개)
madhan ravi
2020년 6월 14일
편집: madhan ravi
2020년 6월 14일
It is correct approach. I suggest you to do MATLAB Onramp course and watch Cleve Moler's videos about odes.
P.S: MATLAB is not able to find the analytical solution.
댓글 수: 5
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!