Filter löschen
Filter löschen

How to plot the number of iterations as a function of the approximation

6 Ansichten (letzte 30 Tage)
Hello, My code provides me with an approximation of pi based on the number of iterations required to escape the Mandelbrot set. I would like to plot the number of iterations (n) as a function of the Approximation, but I can't seem to get a decent graph. I have tried just plotting n,Approximations, as well as a loglog plot (since the iterations get rather large) and I tried changing the marker size encase it was too small. I also tried to create a new loop to save the value from each iteration in a zeros matrix and plot that, but didn't really get anywhere with it. Any thoughts or ideas would be most appreciated. Here is the code:
% Fifth Version
close all;clear all; clc
%Prepared by Lauren Stearns
prompt = 'Input a small, real, positive value for epsilon. Input:';
epsilon = str2double(input(prompt,'s'));
c = 1/4 + epsilon ;
% Where epsilon is a very small, real, positive, number. such as 1e-10
z = 0;
n = 0;
while z < 2
z = z.^2 + c;
n = n+1 ;
end
Approximation = n*sqrt(epsilon);
display(Approximation)
format long
Pi = pi
Comparison = abs(((pi-Approximation)/pi))*100; %%Percent error comparison
display(Comparison)
loglog(n,Approximation,'k-', 'markersize', 12)

Akzeptierte Antwort

KSSV
KSSV am 6 Jun. 2017
I literally, have no idea on what you are doing..but this can be done to plot number of iterations and approximation. You have to rethink on what you are doing:
close all;clear all; clc
%Prepared by Lauren Stearns
prompt = 'Input a small, real, positive value for epsilon. Input:';
epsilon = str2double(input(prompt,'s'));
c = 1/4 + epsilon ;
% Where epsilon is a very small, real, positive, number. such as 1e-10
z = 0;
n = 0;
while z < 2
z = z.^2 + c;
n = n+1 ;
end
Approximation = [1:n]*sqrt(epsilon);
% display(Approximation)
format long
Comparison = abs(((pi-Approximation)/pi))*100; %%Percent error comparison
% display(Comparison)
loglog(1:n,Approximation,'k-', 'markersize', 12)

Weitere Antworten (0)

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by