How does one plot this fractal?

4 ビュー (過去 30 日間)
Karan Sandhu
Karan Sandhu 2016 年 3 月 8 日
コメント済み: Karan Sandhu 2016 年 3 月 8 日
The equations for the fractal are given in the first picture. Here is my code for plotting them. I am having trouble actually plotting them onto the graph. Also, let's say I wanted to plot multiple graphs of this fractal, as shown in the second picture. How would I do this with a single for loop? Any suggestions?
% test code to plot the first graph
x(1)=0;
y(1)=0;
for k=[1:250]
x(k+1)=(y(k)*(1+sin(0.7*x(k))))-1.2*sqrt(abs(x(k)));
y(k+1)=0.21-x(k);
end
subplot(2,2,1)
plot(x(k),y(k))
xlabel('x')
ylabel('y')
title('Fractal Plot with 250 points')

採用された回答

Chad Greene
Chad Greene 2016 年 3 月 8 日
For the two parts of your question:
1. When you call plot you're only plotting x(k),y(k), which is only the very last value. I think you want this:
plot(x,y,'.','markersize',8)
2. To use only one loop, run the loop for k=1:2500 or whatever your final value is. When you plot the first 250 results use:
plot(x(1:250),y(1:250),'.','markersize',8)
and change the range of x,y values to plot 1:1000 results or whatever range you want to plot.
  1 件のコメント
Karan Sandhu
Karan Sandhu 2016 年 3 月 8 日
Thank you sir

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by