Question
MATLAB QUESTION Find the general solution of the given application of differential equation using MATLAB. NOTE:...
MATLAB QUESTION
Find the general solution of the given application of differential equation using MATLAB.
NOTE: Screenshot the MATLAB ENVIRONMENT together with the CODES and FINAL ANSWERS.
Answers
ANSWER:
- I have provided the properly commented code in both text and image format so you can easily copy the code as well as check for correct indentation.
- I have provided the output image of the code so you can easily cross-check for the correct output of the code.
- Have a nice and healthy day!!
CODE TEXT
% first order diffrential equation
% for E = 50*sin(20t), R = 5, I(inductance) = 0.4 Henrys, current=i is
% I (di/dt) + R.i = E(t)
% using syms and dsolve methods of matlab
syms curr(t)
% defining other given variables
I = 0.4;
R = 5;
E = 50*sin(20*t);
% defining equation
eqn = I*diff(curr,t) + R*curr == E;
% defining initial condition
cond = curr(0) == 0;
% solving equation using dsolve w.r.t initial condition
currSol(t) = dsolve(eqn,cond);
% finding current for T=1:100 using solution, converting sym solve to
% double
T = 1:100;
current = double(currSol(T));
% ploting the result
plot(T,current);
xlabel('Time');
ylabel('Current');
title('Time vs current for I (di/dt) + R.i = E(t)')
CODE/ENVIRONMENT IMAGE
OUTPUT IMAGE