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

Incorrect

40Size
Leading solution size is 16.
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
 
w=100;
[xm ym]=meshgrid(1:w);
% simple ellipsoid
z(xm(:)+(ym(:)-1)*w)=sqrt(1-(xm(:)/142).^2-(ym(:)/142).^2);
z=reshape(z,w,w);
z_orig=z; % used for performance check
%figure(42);surf(z,'LineStyle','none')
% or ellipsoid by for loops
%for i=1:w
% for j=1:w
%  z(i,j)=sqrt(1-(i/142)^2-(j/142)^2);
% end
%end
z(50,50)=0;
%figure(43);surf(z,'LineStyle','none')
tic
out = Fix_interferometer(z);
toc
delta=abs(out-z_orig);
fprintf('Max delta=%e\n',max(delta(:)))
assert(max(delta(:))<1e-4,sprintf('Max delta=%f\n',max(delta(:))))
Error: Matrix dimensions must agree.
2
Fail
 
%%
% Load a real Interferometry Profile
%   Previously TriScatteredInterp corrected
% Randomly induce Drop-Outs
tic
urlwrite('http://tinyurl.com/matlab-interferometer','Inter_zN.mat')
load Inter_zN.mat
toc
zN_orig=zN;
%figure(44);surf(zN_orig,'LineStyle','none')
zN_idx=find(~isnan(zN));
for i=1:20
 zN(zN_idx(randi(size(zN_idx,1))))=0;
end
%figure(45);surf(zN,'LineStyle','none')
tic
out = Fix_interferometer(zN);
toc
delta=abs(out-zN_orig);
fprintf('Max delta=%e\n',max(delta(:)))
% Threshold based on a handful of test cases
assert(max(delta(:))<5e-7,sprintf('Max delta=%f\n',max(delta(:))))
Error: NaN's cannot be converted to logicals.