Looking to get some help on how to use matlab to solve the following equation problem 1, all help is appreciated! Thank You! I haven't used matlab in 2 years very rusty, image is reference to original problem statement. List of equations
%%PROBLEM 1
syms y(x)
ode = y*diff(y,x)+36*x == 0;
ySol(x) = dsolve(ode)
ezplot(y(x))

 채택된 답변

Star Strider
Star Strider 2018년 1월 17일

3 개 추천

The integrated equations produce results that are pure imaginary. You have to plot the real and imaginary parts of each solution separately with ezplot. You also have to define the initial condition, y(0).
Try this:
syms y(x)
ode = y*diff(y,x)+36*x == 0;
ySol = dsolve(ode, y(0) == 0)
figure
subplot(2,1,1)
ezplot(real(ySol(1)))
subplot(2,1,2)
ezplot(imag(ySol(1)))
figure
subplot(2,1,1)
ezplot(real(ySol(2)))
subplot(2,1,2)
ezplot(imag(ySol(2)))

댓글 수: 3

Thank you, it looks like it is working on all my first order equations. Would you do something different if you had a second order differential equation?
Yes, if the second-order differential equation required it.
What if the differential equation is not homogenic?

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

추가 답변 (1개)

Ritesh
Ritesh 2023년 12월 22일

0 개 추천

syms y(x) ode = y*diff(y,x)+36*x == 0; ySol = dsolve(ode, y(0) == 0) figure subplot(2,1,1) ezplot(real(ySol(1))) subplot(2,1,2) ezplot(imag(ySol(1))) figure subplot(2,1,1) ezplot(real(ySol(2))) subplot(2,1,2) ezplot(imag(ySol(2)))

댓글 수: 1

Dyuman Joshi
Dyuman Joshi 2023년 12월 22일
편집: Dyuman Joshi 2023년 12월 22일
This non-formatted code is copy-pasted from Star Strider's (accepted) answer.
If you want to give an answer, I recommend you provide an original one. This blatantly copied answer will be deleted soon.
And if you had researched a bit to give an original answer, you would have found out the using ezplot is not recommended.

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

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2018년 1월 17일

편집:

2023년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by