I'm trying to plot differential equations but it's showing errors.

2 views (last 30 days)
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
Please help me to solve this problem

Answers (1)

Ameer Hamza
Ameer Hamza on 6 Dec 2020
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().

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!