Question: MATLAB I have to create a function in MATLAB for a fractal. Something like function []=julia(c,m) . I have tried coding it like my professor,

MATLAB

I have to create a function in MATLAB for a fractal. Something like function []=julia(c,m). I have tried coding it like my professor, but I cannot get it to work when I put it into MATLAB. Any help would be great. Here is what I have to do (below):

B. To do: 1. julia0.m code: Implement the "escape-time algorithm" in a matlab script "julia0.m". a. Good default values are: W=2 (WINDOW WIDTH), M=100 (NUMBER OF GRID POINTS IN EACH DIRECTION) , R=2 (ESCAPE RADIUS) , maxIT=20 (MAX NUMBER OF ITERATIONS), Ncolors=64, and to start with c = 0.3+0.4i . Play around with the program trying different parameter values to see the effect, e.g. R = 3, M = 50 or 200, etc. Different fractal shapes appear for different c . Some interesting ones are: c = 1, c = 10.1i , c = 0+i ("dendrite"), c = 0.123+0.745i ("Douadi rabbit") Try them! b. Other powers may also work, try the cubic: z = z^3 + c, and 4th degree: z = z^4 + c with c=1 2. julia2.m code: a. Copy your (debugged) "julia0.m" to new file "julia2.m" and modify it into a Matlab function with two input arguments: c , M . Test and debug with various inputs. b. Then make it more flexible, so as one can call it with 2 or 1 or 0 arguments [use "if( nargin ) < 2" and "if( nargin ) < 1" and insert defaults for appropriate parameters]. Test and debug with 2, with 1, with no inputs. c. Insert short comments explaining what is being done.

C. What to submit, in a single TEXT file "lab13.txt": 1. The "c" value that generated your favored pattern.

Here is what my professor's coding looks like:

function []=julia(c) % c= 0.3+0.5*i; W=2; M=100; R=2; maxIT=20; dx=2*W/M; dy=2*W/M; % grid ix=0 for x=-W:dx:W ix=ix+1; iy=0 for y=-W:dy:W iy=iy+1; z=x+i*y; end %while

IT(iy,ix)=k;

end % fory end % forx

%coloring IT=Ncolors*(1-IT/maxIT)

%plot pcolor([-W:dx:W],[-W:dy:W],IT)

end % function

if (nargin <1) c=0.2-0.4*i;

end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!