How can i plot a non-linear difrential equation in MATLAB?
Answer:
You can use ezplot or fplot functions.They're really easy.
1)courses.washington.edu/css45...
2) www.mathworks.com/access/helpd...
You didnt mention whether or not it was ordinary or partial differential equation.
A tool that I really like is the ode45 family of functions.
Using standard methods you can make your nth order ode into a family of n first order equations. You build a m-file for it that is consistent with the ode45 code example, and you run ode45. If ode45 doesnt work, the other variants (ode23 or ode113) will likely work. Try the variants until it works.
The examples in the help file are sufficient for this. Try "helpwin ode45" at the command prompt.
so here is the m-file function for the van-der-pol nonlinear ode. (copyright Mathworks, taken from help docs, less than 10% of content)
function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1);
return
here is the code to make the plot of this function
[T,Y] = ode15s(@vdp1000,[0 3000],[2 0]);
plot(T,Y(:,1),'-o')
If you want an example of converting to lower order, look at pages 76-82 of Modern Control Engineering (4th ed) by Katsuhiko Ogata (2002). The examples there are typically linear, but the method gives a bootstrap into making setting up nonlinear odes.
The answers post by the user, for information only, FunQA.com does not guarantee the right.
More Questions and Answers: