# Guys, need help with matlab: can't plot graph (differential equations)

Discussion in 'Programmer's Corner' started by Gudsaf, May 23, 2013.

1. ### Gudsaf Thread Starter New Member

May 23, 2013
1
0
So, good day.
I had problem with matlab: can't plot graph.
Need to say u, i from Russia, maybe my language bad, so sorry))
Maybe u can give advice - where (what forum) can help me?

My equation: My code:
Code ( (Unknown Language)):
1.
2. T = [0 5e-6];
3. i0 = [0 0];
4. [t, I] = ode45('qweq',T,i0);
5.     % печатаем график i(t) / print i(t)
6.     figure
7.     plot(t,I(:,1))
8.     grid on
9.     legend('i(t)')
10.     xlabel('t')
11.     ylabel('i')
12.     title('График зависимости тока от времени')
13.     % печатаем график di/dt / print di/dt
14.     figure
15.     plot(t,I(:,2))
16.     grid on
17.     legend('di/dt')
18.     xlabel('dt')
19.     ylabel('di')
20.     title('График зависимости di по dt')
21.
Function:
Code ( (Unknown Language)):
1.
2. function F = qweq(t,I)
3.     R0 = 2;
4.     L = 1e-6;
5.     C = 0.001e-6;
6.     f = 1e6;
7.     k = 8e10;
8.     Um = 1;
9.
10. w = 2*pi*f;
11. R = R0*(1-k*I(1)^2);
12.
13. F = zeros(2,1);
14. F(1) = I(2);
15. F(2) = ( Um*w*cos(w*t) - (1/C)*I(1) - R*I(2) )/L;
16.
if i set k as 0, all ok. But in task k must be 8e10...