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 106530

Submitted on 5 Jul 2012

Incorrect

14Size
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
Fail
 
%%
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))
Error:
1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1.000000 0.000000 1.000000 0.000000 1.000000 1.000000
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.471303842338459 + 0.058587820058606i
 -0.222335091974530 + 0.158352541485793i
 -0.202605268967038 + 0.050429889947843i
 -0.346498602965218 - 0.222887114575951i
 -0.317018488037869 - 0.220249517087588i
 -0.003144833702124 - 0.032846920020152i
3
Fail
 
%%
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))
Error:
0.437143 0.423339 0.109213 0.241322 -0.076958 -0.138063
1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
0.000000 0.000000 1.000000 1.000000 1.000000 1.000000