Filter löschen
Filter löschen

To find the meaning of this code

3 Ansichten (letzte 30 Tage)
Raghav Mathur
Raghav Mathur am 1 Jun. 2020
Beantwortet: Drishti Jain am 2 Jun. 2020
MatLab Programming:-
%% Main File
clc;
clear all;
close all;
[t,x]=ode45(@rlcckt,[0 1],[0 0]);
plot(t,x(:,1),'m');
hold on plot(t,x(:,2),'b');
legend('x1','x2');
%% Function File
function dx=rlcckt(t,x)
dx = zeros(2,1);
Vin=5;
R=5;
C=10;
L=0.5;
dx(1)=x(2);
dx(2)=(Vin/L)-((R/L)*x(2))-((1/L*C)*x(1));
end

Akzeptierte Antwort

Drishti Jain
Drishti Jain am 2 Jun. 2020
It solves two differential equations and plots the solution for them.
[t,x]=ode45(@rlcckt,[0 1],[0 0]);
ode45 integrates the system of differential equations (the ODEs are specified in function rlcckt) from t=0 to t=1 ([0 1]) with inital conditions [0 0].
plot(t,x(:,1),'m');
hold on plot(t,x(:,2),'b');
legend('x1','x2');
Here, you are plotting the two solutions in the same figure with time in the x axis.

Weitere Antworten (0)

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by