I'm trying to plot differential equations but it's showing errors.
3 次查看(过去 30 天)
显示 更早的评论
Here is the code.....
clc
clear all
close all
syms i(t)
di = diff(i);
d2i = diff(i,2);
z = dsolve((d2i+40*di+1000*i(t)) == 0.1*diff(heaviside(t)));
i(0)==4;
di(0)==15;
z1 = diff(z); % ANS OF BIT a
subplot(2,1,1)
ezplot(z)
title('STEP RESPONCE')
xlabel('time (t)');
ylabel('(z)');
grid on;
gtext('1841014009');
subplot(2,1,2)
ezplot(z1)
title('IMPLUSE RESPONCE')
xlabel('time (t)');
ylabel('(z1)');
grid on;
gtext('1841014009');
And here is the errors
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/449713/image.png)
Please help me to solve this problem
0 个评论
回答(1 个)
Ameer Hamza
2020-12-6
You are not applying the initial condition with solving the ode. Check the following code
clc
close all
syms i(t)
di = diff(i);
d2i = diff(i,2);
cond = [i(0)==4; di(0)==15];
z = dsolve((d2i+40*di+1000*i(t)) == 0.1*diff(heaviside(t)), cond);
z1 = diff(z); % ANS OF BIT a
subplot(2,1,1)
fplot(z)
title('STEP RESPONCE')
xlabel('time (t)');
ylabel('(z)');
grid on;
gtext('1841014009');
subplot(2,1,2)
fplot(z1)
title('IMPLUSE RESPONCE')
xlabel('time (t)');
ylabel('(z1)');
grid on;
gtext('1841014009');
Also, fplot() is recommended instead of ezplot().
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!