Cody

# Problem 378. Inhomogenous Depth Scale Interpolation

Solution 1769978

Submitted on 2 Apr 2019 by Abdelfatah Teamah
• Size: 9
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
% Test to make sure there are no for loops fid = fopen('interp_v_at_d.m'); text = fread(fid)'; fclose(fid); assert( isempty( strfind( text, 'for' ) ) )

2   Pass
% Test to make sure there are no while loops fid = fopen('interp_v_at_d.m'); text = fread(fid)'; fclose(fid); assert( isempty( strfind( text, 'while' ) ) )

3   Pass
% Test to make sure it works m = 1; z = cat(3,zeros(m),sort(rand([m,m,10]),3),ones(m)); v = randn([m,m,12]); d = rand(); v2 = interp_v_at_d(z,v,d); v2_correct = zeros(m,m); for i = 1:m for j = 1:m v2_correct(i,j) = interp1(squeeze(z(i,j,:)),squeeze(v(i,j,:)),d); end end assert( isequal( v2_correct, v2 ) );

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In interp_v_at_d (line 2) In ScoringEngineTestPoint3 (line 6) In solutionTest (line 7)]

4   Pass
% Test to make sure it works m = 5; z = cat(3,zeros(m),sort(rand([m,m,10]),3),ones(m)); v = randn([m,m,12]); d = rand(); v2 = interp_v_at_d(z,v,d); v2_correct = zeros(m,m); for i = 1:m for j = 1:m v2_correct(i,j) = interp1(squeeze(z(i,j,:)),squeeze(v(i,j,:)),d); end end assert( isequal( v2_correct, v2 ) );

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In interp_v_at_d (line 2) In ScoringEngineTestPoint4 (line 6) In solutionTest (line 9)]

5   Pass
% Test to make sure it works m = 10; z = cat(3,zeros(m),sort(rand([m,m,10]),3),ones(m)); v = randn([m,m,12]); d = rand(); v2 = interp_v_at_d(z,v,d); v2_correct = zeros(m,m); for i = 1:m for j = 1:m v2_correct(i,j) = interp1(squeeze(z(i,j,:)),squeeze(v(i,j,:)),d); end end assert( isequal( v2_correct, v2 ) );

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In interp_v_at_d (line 2) In ScoringEngineTestPoint5 (line 6) In solutionTest (line 11)]

6   Pass
% Test to make sure it works m = 25; z = cat(3,zeros(m),sort(rand([m,m,10]),3),ones(m)); v = randn([m,m,12]); d = rand(); v2 = interp_v_at_d(z,v,d); v2_correct = zeros(m,m); for i = 1:m for j = 1:m v2_correct(i,j) = interp1(squeeze(z(i,j,:)),squeeze(v(i,j,:)),d); end end assert( isequal( v2_correct, v2 ) );

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In interp_v_at_d (line 2) In ScoringEngineTestPoint6 (line 6) In solutionTest (line 13)]

7   Pass
% Test to make sure it works m = 100; z = cat(3,zeros(m),sort(rand([m,m,10]),3),ones(m)); v = randn([m,m,12]); d = rand(); v2 = interp_v_at_d(z,v,d); v2_correct = zeros(m,m); for i = 1:m for j = 1:m v2_correct(i,j) = interp1(squeeze(z(i,j,:)),squeeze(v(i,j,:)),d); end end assert( isequal( v2_correct, v2 ) );

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In interp_v_at_d (line 2) In ScoringEngineTestPoint7 (line 6) In solutionTest (line 15)]