I'm a new user of MATLAB and I already met some difficulties with my MATLAB program. It consists in plot Brownian and Bachelier cartoon exactly as you can see following this link.
Such function is similar to Bolzano's function. Can someone give me some advice concerning how to generate the new points?

2 Kommentare

Andrew Newell
Andrew Newell am 14 Apr. 2011
What have you tried and what difficulties have you had?
Samuel
Samuel am 25 Apr. 2011
Bearbeitet: Walter Roberson am 9 Mär. 2024
I tried something obtaining a partial result. So far my code is the following
function [x,y]=cartoon(n)
H=1/2; %Hurst's exponent
if nargin ~= 1
n = 4;
end
% end of recursion
if n <= 0
x = [0 1];
y = [0 1];
% recursive method call
else
[x0,y0] = cartoon(n-1);
% calculate new co-ordinates
x = (4/9)*[x0 x0+5/4];
y = 2/3*[y0 y0+H];
end
plot(x,y,'-');
hold off;
end
The code start to divide the straight and rise line in 3 unlike parts creating a generator with a central interval [4/9,5/9] and so on. But the code is not complete because it doesn't apply the generator in the central intervals (like [4/9,5/9] and the others that step by step are generated). How can I settle my code so that I get the intentional result?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Andrew Newell
Andrew Newell am 25 Apr. 2011

1 Stimme

The key point you are missing is that you need to feed in the coordinates of the endpoints as well as n. That will allow you to recursively call cartoon for each subinterval. Here is a code that will do what you want:
function [x,y]=cartoon(x,y,n,H)
if nargin < 3
n = 4;
end
if nargin < 4
H = 1/2; % Hurst's exponent
end
% If n <=0, x and y are equal to the input.
if n > 0
% Create the first division.
x = x(1) + (x(2)-x(1))*[0 4/9 5/9 1];
y = y(1) + (y(2)-y(1))*[0 2/3 2/3*H 1];
% Subdivide each interval recursively.
[x1,y1] = cartoon(x(1:2),y(1:2),n-1,H);
[x2,y2] = cartoon(x(2:3),y(2:3),n-1,H);
[x3,y3] = cartoon(x(3:4),y(3:4),n-1,H);
% The vectors x1,x2,x3 overlap at their endpoints.
x = [x1 x2(2:end) x3(2:end)];
y = [y1 y2(2:end) y3(2:end)];
end
Note that I have also removed the plot command from inside the function. You can now recreate the left plot using a loop like this:
for i=1:4
subplot(4,1,i)
[x,y] = cartoon([0 1],[0 1],i,1/2);
plot(x,y)
end
For the right hand plots, you'll need to run cartoon on each of the two line segments and piece the results together.

2 Kommentare

Samuel
Samuel am 25 Apr. 2011
Perfect! Thank you so much!
Shin Kelly
Shin Kelly am 30 Dez. 2012
wow.. this is fabulous work,,,
hello I'm highschool student studying fractal and trying to observe(?) it in animals' organ..
Can you give me some advice for generalizing the photo(of organ) and caculate the fractal dimension? Please,,

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Fractals finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by