I want to create matrix in MATLAB like this
which Identitas is identity matrix, Nol is zero matrix, min1 and mina is defined in the this code MATLAB below.
clear all;
clc;
h=0.2;
x=0:h:2;
k=0.2;
t=0:k:2;
N=length(x);
J=length(t);
a=4*h^2/k;
Identitas=eye(N,N);
Nol=zeros(N,N);
min1=zeros(N,N);
for i=2:N
for j=2:N
if i==j
min1(i,j)=-1;
end
end
end
mina=zeros(N,N);
mina(1,1)=1;
for i=2:N
mina(i,i-1)=-a;
mina(i,i)=a+2;
end
MK(1,1)=Identitas;
for j=2:J-1
MK(j,j-1)=min1;
MK(j,j)=mina;
MK(j,j+1)=min1;
end
MK(J,J)=Identitas;
That code give me error, because MATLAB cannot store a matrix in the array. So how to make that matrix in MATLAB?