This is driving me crazy and I don't know another way to formulate the question but to type the code (It's really simple)
Step1: Create a matrix. (We will call it "D")
Step2: Solve a matrix differential equation.
Step3: Compute the result.
This is the code:
%%
clc;clear all;close all;%% STEP 1. GET THE DATA
n_of_states = 28;% Define the failure rates
dsw= 0.0215;dd= 0.005186;daux_gen=0.262+0.161+0.03+0.012;dc= [0.1294 0.4334 0.8725];dar= 6*dsw+daux_gen;dpr= 6*dd;%% STEP 2. CREATION OF A MATRIX (transition intensity matrix)
%The matrix dimension will be: (n_of_states x n_of_states)
D=zeros(n_of_states);%We introduce the failure rate of the active rectifier
D(1,13)=dar;D(4,14)=dar;D(7,15)=dar;D(10,16)=dar;D(2,17)=dar;D(5,18)=dar;D(8,19)=dar;D(11,20)=dar;D(3,21)=dar;D(6,22)=dar;D(9,23)=dar;D(12,24)=dar;%We introduce the failure rate of the capacitor (1)
D(1,2)=dc(1);D(4,5)=dc(1);D(7,8)=dc(1);D(10,11)=dc(1);%We introduce the failure rate of the capacitor (2)
D(2,3)=dc(2);D(5,6)=dc(2);D(8,9)=dc(2);D(11,12)=dc(2);%We introduce the failure rate of the capacitor (3)
D(3,25)=dc(3);D(6,26)=dc(3);D(9,27)=dc(3);D(12,28)=dc(3);%We introduce the failure rate of the passive rectifier
D(1,4)=3*dpr;D(2,5)=3*dpr;D(3,6)=3*dpr;D(4,7)=2*dpr;D(5,8)=2*dpr;D(6,9)=2*dpr;D(7,10)=dpr;D(8,11)=dpr;D(9,12)=dpr;%Completition
vector_sum=sum(D,2); %We create a vector with the sum of each row
for i = 1:n_of_states D(i,i)=-vector_sum(i);end
Then (here it comes the problem), I do this:
syms p(t) [1 n_of_states];Y=p;%This is the matrix system
odes = diff(Y) == Y*D;%This is the initial condition
C=zeros(1,n_of_states);C(1)=1;cond = p(0) == C;%This should be the solution
[p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28] = dsolve(odes,cond);reliability=p1+p2+p3+p4+p5+p6+p7+p8+p9+p10+p11+p12;reliability=vpa(reliability,3);
and I obtain the function called "reliability".
Why is that function different to the one (called "rel") obtained doing this?
syms probabilidad(t) [1 n_of_states];Y=probabilidad;%This is the matrix systemode = diff(Y) == Y*D;%This is the initial conditionC=zeros(1,n_of_states);C(1)=1;condition = probabilidad(0) == C;%This should be the solutionJ = dsolve(ode,condition);rel=J.probabilidad1+J.probabilidad2+J.probabilidad3+J.probabilidad4+J.probabilidad5+J.probabilidad6+J.probabilidad7+J.probabilidad8+J.probabilidad9+J.probabilidad10+J.probabilidad11+J.probabilidad12;rel=vpa(rel,3);
And most importantly, WHICH ONE IS CORRECT??????? I'm desesperated!
Best Answer