graph - Plotting iteratively defined function in MATLAB -
i'm not matlab professional , so, need @ producing 3d plot of iteratively defined function f : r^2-0 -> r defined below (in pseudocode) x,y values in [-1,1] and
for each i = 1,2,3 , a = (0.5,0.5)
function f(v in r^2-0) { a=b=0; (a,b in r) (i=0; i<i; i=i+1) { v = |v| / ||v||^2 - a; = + | ||v||-b |; b = ||v||; } return a; }
(|v| denotes component-wise vector absolute value)
(if want can @ fractal generated function @ question on math-exchange here:
matlab code appreciated.
much thanks.
save main program:
clear clc close % = 1; % = [ 0.5 0.5 ]; = 10; = [ 0.5 0.5 0.5 ]; xmin = -1; xmax = 1; ymin = -1; ymax = 1; nx = 101; ny = 101; dx = (xmax - xmin) / (nx - 1); dy = (ymax - ymin) / (ny - 1); x = xmin: dx: xmax; y = ymin: dy: ymax; ix = 1: nx iy = 1: ny if (length(a) == 2) z(iy, ix) = f([x(ix) y(iy)], a, i); elseif (length(a) == 3) z(iy, ix) = f([x(ix) y(iy) 0], a, i); end end end pcolor(x, y, z) shading interp
then save function in same directory main program f.m
:
function result = f(v, a, i) = 0; b = 0; = 1: v = abs(v) / dot(v, v) - a; = + abs(norm(v) - b); b = norm(v); end result = a; end
Comments
Post a Comment