problem with cellular automata code?
조회 수: 1 (최근 30일)
이전 댓글 표시
i found this code here, and i try to initialize it with [1 0 1 1 0 1 1] but it didn't work.
the code is long to paste it here. and how to locate the image?
댓글 수: 0
채택된 답변
Geoff Hayes
2014년 10월 21일
Sara - how did you try to execute the code? Based on the given link, the function requires a rule (so this is an integer from 1 to 255), an optional initial state, and an optional number of rows (iterations for the cellular automata). What is your [1 0 1 1 0 1 1] - a rule or an initial state?
For example, the command
wolfram(45)
creates an interesting image, as does some of the other examples included in the comments (from the rich vector).
If your vector is an initial state, then you would specify the rule (1-255) and supply the state vector
wolfram(45, [1 0 1 1 0 1 1], 50);
Note that since your initial state is narrow (only 7 columns) then the number of rows should be kept small too else the image will be difficult to view.
댓글 수: 15
cathrin philo
2016년 2월 22일
편집: Geoff Hayes
2016년 2월 23일
thank you for your response.
if nargin < 300, nrows=221; end
if nargin < 300 %Use default initial state
ncols=228; A=zeros(nrows,ncols); A(1,ncols-1)=1;
else
[unused, ncols]=size(initialstate)
A=zeros(nrows, ncols); A(1,:)=initialstate;
end
rule=dec2bin(wolfrule,8);
where i have changed row=221;col=228. i don't know whether the output is for my input image or not? how can i procced with?
Geoff Hayes
2016년 2월 23일
cathrin - you will need to update the wolfram function to return the output A as
function [A] = wolfram(wolfrule, initialstate, grows)
As for changing the nrows and ncols, why have you chosen 221 and 228? Are these the dimensions of your original image? Because I would think that you wouldn't have to modify these numbers at all. For example, suppose you wish to apply to the 40th row of your image which is a 256x512 image. Then you would call wolfram as
A = wolfram(150,myImg(40,:),256-40+1);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!