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

# Solution 127048

Submitted on 13 Aug 2012 by Richard Zapor

Correct

75Size
`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

```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(:))))
```
```Elapsed time is 0.172248 seconds.
Max delta=3.330912e-05
```
2
Pass

```%%
% Load a real Interferometry Profile
%   Previously TriScatteredInterp corrected
% Randomly induce Drop-Outs
tic
urlwrite('http://tinyurl.com/matlab-interferometer','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(:))))
```
```ans =
/users/msssystem13/Inter_zN.mat
Elapsed time is 2.993864 seconds.
Elapsed time is 3.317874 seconds.
Max delta=1.291534e-07
```