one program has different results in different versions

Here is the code:
C=0.3+0.5i;
V = linspace(-2.0,2.0,400);
[Re,Im] = meshgrid(V);
Z = Re + i * Im;
B = 0;
for K = 1:100
B = B+(abs(Z)<=2);
Z = Z.*Z + C;
end;
imagesc(B);
colormap(jet);
axis equal
In 2018a, the result is:
But, in 2015b, the result is:
Why this will happen? How can I get the second figure in 2018a version? Thank you very much.

4 件のコメント

Star Strider
Star Strider 2019 年 5 月 27 日
For what it’s worth, I get the R2015b result in R2019a.
the cyclist
the cyclist 2019 年 5 月 27 日
I get your R2015b result with R2018b. Maybe a bug was introduced between R2015b and R2018a, which was fixed in R2018b?
per isakson
per isakson 2019 年 5 月 27 日
I get your R2015b image with both R2018a and R2018b.
Walter Roberson
Walter Roberson 2019 年 5 月 27 日
Fractal in R2016b, R2017b, R2018a, R2018b, R2019a on Mac
Do you just happen to have an AMD cpu?

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

回答 (1 件)

Steven Lord
Steven Lord 2019 年 5 月 27 日

2 投票

In release R2018a did you assign a value to the variable i before running that code? When you want to ensure that you're using the square root of -1 you should always use 1i. Try replacing your line:
Z = Re + i * Im;
with
Z = Re + 1i * Im;

1 件のコメント

per isakson
per isakson 2019 年 5 月 27 日
編集済み: per isakson 2019 年 5 月 27 日
Yes adding i=1;
%%
i = 1;
C=0.3+0.5i;
etc.
did it
on R2018b

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

カテゴリ

質問済み:

2019 年 5 月 27 日

編集済み:

2019 年 5 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by