jecstir2112
Instructor
Hey, so basically i need to be able to enter the dimensions of a matrix (nxn), take the inverse and, multiply it by another 1xn. I have written a Matlab equiv for this.
clc
Clear all
%% input variables
n = input('Input the number of nodes ')
W = input('Input the length of the slab(W)')
Sig_tr = 0.0362;
Sig_a = 0.1532;
vSig_f = 0.1570;
Rel_abs = 1;
S_o = 10^8;
Lambda_tr = 1/Sig_tr ;
D = Lambda_tr/3;
L = (D/Sig_a)^.5;
dx = W / (n-1);
k = S_o*L/(2*D);
%% matrix formation
%Slab Reactor
A = zeros(n,n);
B = zeros(n,1);
Y = zeros(n,n);
Z = zeros(n,1);
%matrix Parameter Values
Y(1,1) = ((D/dx)+(Sig_a*dx/2));
Y(1,2) = -D/dx;
Z(1,1) = S_o/2;
for icount = 2:n-1
Y(icount,icount) = (2*D)/dx+Sig_a*dx;
Y(icount,icount+1) = -D/dx;
Y(icount,icount-1) = -D/dx;
Z(icount,1) = 0;
end;
A= Y(1:n-1 , 1:n-1);
B = Z(1:n-1);
AAA = inv(A)*B;
% print this output
AAA = 0
clc
Clear all
%% input variables
n = input('Input the number of nodes ')
W = input('Input the length of the slab(W)')
Sig_tr = 0.0362;
Sig_a = 0.1532;
vSig_f = 0.1570;
Rel_abs = 1;
S_o = 10^8;
Lambda_tr = 1/Sig_tr ;
D = Lambda_tr/3;
L = (D/Sig_a)^.5;
dx = W / (n-1);
k = S_o*L/(2*D);
%% matrix formation
%Slab Reactor
A = zeros(n,n);
B = zeros(n,1);
Y = zeros(n,n);
Z = zeros(n,1);
%matrix Parameter Values
Y(1,1) = ((D/dx)+(Sig_a*dx/2));
Y(1,2) = -D/dx;
Z(1,1) = S_o/2;
for icount = 2:n-1
Y(icount,icount) = (2*D)/dx+Sig_a*dx;
Y(icount,icount+1) = -D/dx;
Y(icount,icount-1) = -D/dx;
Z(icount,1) = 0;
end;
A= Y(1:n-1 , 1:n-1);
B = Z(1:n-1);
AAA = inv(A)*B;
% print this output
AAA = 0