Unable to plot iterated function system

5 ビュー (過去 30 日間)
Fue Xiong
Fue Xiong 2022 年 1 月 19 日
編集済み: Torsten 2022 年 1 月 19 日
I'm trying to plot an iterated function system based on the Barnsley Fern. The fractal is started at point (0,0) and generates new points by using 4 transformations. I received several errors and an empty graph. Any suggestions on how to go around this. I'm new to MATLAB and thanks for any help.
Errors
Graph

採用された回答

Torsten
Torsten 2022 年 1 月 19 日
編集済み: Torsten 2022 年 1 月 19 日
function Modern_Art
A{1} = [1;2];
n = 100;
r = rand(100,1);
for i=1:100
if r(i)<0.01
A{i+1} = [0 0;0 0.16]*A{i};
elseif 0.01 <= r(i) && r(i) < 0.86
A{i+1} = [0.85 0.04;-0.04 0.85]*A{i} + [0;1.6];
elseif 0.86 <=r(i) && r(i) < 0.93
A{i+1} = [0.2 -0.26;0.23 0.22]*A{i} + [0;1.6];
elseif 0.93 <= r(i) && r(i) < 1
A{i+1} = [-0.15 0.28;0.26 0.24]*A{i} + [0;0.44];
end
end
A = cell2mat(A);
plot(A(1,:),A(2,:))
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFractals についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by