Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 107464

Submitted on 6 Jul 2012 by Freddy

Correct

45Size
Leading solution size is 22.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
format long
v=[-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25];
tf=isMandelbrot(v);
tf_expected=[1 ; 0 ; 1 ; 0 ; 1 ; 1] ;
assert(isequal(tf,tf_expected),sprintf('\n%f %f %f %f %f %f',tf,tf_expected))

                    
2
Pass
 
%%
v=-.25*ones(6,1)+(rand(6,1)-.5)/2+i*(rand(6,1)-.5)/2
%v=[-.5-.25i;-.5+.25i;-.25i;.25i;-.25-.25i;-.25+.25i]
% Bounding Cases
tf=isMandelbrot(v);
tf_expected=[1 ; 1 ; 1 ; 1 ; 1 ; 1] ;
assert(isequal(tf,tf_expected),sprintf('\n%f %f %f %f %f %f',tf,tf_expected))
v =
 -0.234681845791975 - 0.026563169634724i
 -0.433113175739611 - 0.174447587147998i
 -0.494788758352610 - 0.037486334793310i
 -0.295805640919895 - 0.121779766700902i
 -0.043685327589486 + 0.011001671917280i
 -0.491306840504999 - 0.192060381584953i
3
Pass
 
%%
v=rand(6,1)-0.25
tf=isMandelbrot(v);
tf_expected=v<=0.25; % non-imaginary range [-2.0,0.25]
assert(isequal(tf,tf_expected),sprintf('\n%f %f %f %f %f %f',v,tf,tf_expected))
v =
   0.547275158727325
  -0.201481753703375
   0.152793233462561
   0.088854379131585
   0.422659681909446
   0.039919707857350