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!