clear all;
clc;
%% Creating a grid with random value
n = 64;
Gpop = rand(n,n);
temp=Gpop;
Gpop(temp(:,:)<0.99) = 1; %Healthy percentage 99%
Gpop(temp(:,:)>0.99 & temp(:,:)<0.994) = 2; %Healthy percentage .04%
Gpop(temp(:,:)>0.994 & temp(:,:)<0.998) = 3; %Healthy percentage .04%
Gpop(temp(:,:)>0.998) = 4; %Healthy percentage .02%
%% Our Rules of cellular automata
x = 2:n-1; % Intializing x and y values to access the cells of CA
y = 2:n-1;
rule = Gpop;
figure
count=0;
time = 0;
while(count<25)
rule((rule(x-1,y-1)==2)|(rule(x,y-1)==2)|(rule(x+1,y-1)==2)|(rule(x-1,y)==2)|(rule(x+1,y)==2)...
|(rule(x-1,y+1)==2)|(rule(x,y+1)==2)|(rule(x+1,y+1)==2) & time==1)=2 ; %1st Rule a
if((rule(x,y-1)==3)| (rule(x-1,y)==3)|(rule(x+1,y)==3)|(rule(x,y+1)==3) & time ==2);
rule(x,y)==2;
else((rule(x-1,y-1)==3)|(rule(x+1,y-1)==3)|(rule(x-1,y+1)==3)|(rule(x+1,y+1)==3) & time ==3);
rule(x,y)==2;
end
rule((rule(x-1,y-1)==3)|(rule(x,y-1)==3)|(rule(x+1,y-1)==3)|(rule(x-1,y)==3)|(rule(x+1,y)==3)...
|(rule(x-1,y+1)==3)|(rule(x,y+1)==3)|(rule(x+1,y+1)==3) & time==4)=3; %2nd rule
rule((rule(x-1,y-1)==4)|(rule(x,y-1)==4)|(rule(x+1,y-1)==4)|(rule(x-1,y)==4)|(rule(x+1,y)==4)...
|(rule(x-1,y+1)==4)|(rule(x,y+1)==4)|(rule(x+1,y+1)==4&time==6))=4; %3rd rule
newMatrix=rand(n,n);
newtemp=newMatrix;
newMatrix(newtemp(:,:)<=.1)=1;
newMatrix(newtemp(:,:)>.1)=0;
rule(((rule(x-1,y-1)==4)|(rule(x,y-1)==4)|(rule(x+1,y-1)==4)|(rule(x-1,y)==4)|(rule(x+1,y)==4)...
|(rule(x-1,y+1)==4)|(rule(x,y+1)==4)|(rule(x+1,y+1)==4)) & newMatrix(x,y)==1 & time == 8)=1; %1st part 4th rule
rule(((rule(x-1,y-1)==4)|(rule(x,y-1)==4)|(rule(x+1,y-1)==4)|(rule(x-1,y)==4)|(rule(x+1,y)==4)...
|(rule(x-1,y+1)==4)|(rule(x,y+1)==4)|(rule(x+1,y+1)==4)) & newMatrix(x,y)==0 & time == 10)=2; %1st part 4th rule
imagesc(rule)
axis off;
cmap = jet(4); % assign colormap
colormap(cmap)
hold on
L = line(ones(4), ones(4), 'LineWidth',2); % generate line
set(L,{'color'},mat2cell(cmap,ones(1,4),3)); % set the colors according to cmap
legend('H','I1','I2','D') %Addings Legends at the top right corner of image
count=count+1;
time = time+1;
pause(3.0)
end
위의 내용은 HIV 바이러스 4 단계를 시뮬레이션하기위한 세포 자동화 코드입니다. 위의 코드를 실행하면 변경되지 않은 상태로 오른쪽 셀이 남아 있습니다. 뭐가 잘못되었지만 할 수 없는지 찾기 위해 열심히 노력했습니다.내 셀룰러 오토마타 코드가 작동하지 않을 때
따라 내 오토마타의 규칙
규칙 1은 : (i) 적어도 하나가 H 셀 만족 아래의 규칙 중 적어도 하나는, 그 다음 단계에서 I1 셀지면 가장 가까운 이웃 또는 제 2 가장 가까운 이웃에있는 I1 셀; (ii) 가장 가까운 이웃에 적어도 x I2 셀, 두 번째로 가까운 이웃에 y I2 셀.
규칙 2 : I1 셀은 다음 단계에서 I2 셀이됩니다.
규칙 3 : I2 세포는 τ 단계 이후 D 세포가되며 면역 학적 인식과 명확성 때문에.
규칙 4 : D 셀은 확률이 Pinf 인 I1 셀로 대체되거나 다음 단계에서 확률 (Prep - Pinf)이있는 H 셀로 대체 될 수 있습니다.
내 코드가 이러한 규칙과 일치하는지 그리고 바이러스의 정확한 시뮬레이션을 얻으려면 코드에서 변경해야 할 사항을 알고 싶습니다. 제발 아무도 나를 도와주세요. 미리 감사드립니다
오른쪽 셀이 변경되지 않고 그대로 남아 있다는 것은 무엇을 의미합니까? _? –
제 60 열의 셀은 시뮬레이션이 수행 된 후 변경되지 않은 상태로 남아 있습니다. 코드를 실행 한 후 이미지가 변경되어 나타나는 것처럼 보입니다. u 이미지를 올바르게 관찰하면 이미지의 오른쪽이 변경되지 않고 그대로 남아 있지만 그럴 필요가 없습니다. 단지 코드에 결함이 있는지,이 셀룰러 오토 마톤을 시뮬레이션하기 위해 변경해야하는 변경 사항을 알고 싶습니다. 제발 내가 사이에 붙어 있고 나는 우둔 해요. – Hari