Cody

Solution 1703914

Submitted on 7 Jan 2019
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   Fail
M=zeros(256); terms=6; % Number of Terms to fit 0:terms-1 % Test Suite portion using zern_data_v01 [ ydim xdim ] = size(M); x = linspace(-1,1,xdim); y = linspace(1,-1,ydim); [X Y] = meshgrid(x,y); R = sqrt(X.^2 + Y.^2); T = atan2(Y,X); % Create surface z_fit=zeros(terms,1); % Map 0:9 to 1:10 z_fit(2)=1.0; % Build a Surface M = M + zern_data_v01(0,R,T); % Force NaN for non-data M(M==0)=NaN; M(M>0)=0; for term = 0:terms-1 M = M + z_fit(term+1) * zern_data_v01(term,R,T); % figure(3);imagesc(data_fit) % Visualization % pause (0.5) end % Data is a circle % Non-data is assigned NaN tic v = Zernike_Fit(M,terms,R,T) toc assert(max(abs(v-z_fit))<0.01,sprintf('v=%i %i %i %i %i %i',v))

Attempt to execute SCRIPT zern_data_v01 as a function: /users/mss.system.4bohAI/zern_data_v01.m Error in Test1 (line 15) M = M + zern_data_v01(0,R,T); % Force NaN for non-data

2   Fail
M=zeros(256); terms=10; % Number of Terms to fit 0:terms-1 % Test Suite portion using zern_data_v01 [ ydim xdim ] = size(M); x = linspace(-1,1,xdim); y = linspace(1,-1,ydim); [X Y] = meshgrid(x,y); R = sqrt(X.^2 + Y.^2); T = atan2(Y,X); % Create surface z_fit= round(2*rand(terms,1)-1).*rand(terms,1); % Build a Surface M = M + zern_data_v01(0,R,T); % Force NaN for non-data M(M==0)=NaN; M(M>0)=0; for term = 0:terms-1 M = M + z_fit(term+1) * zern_data_v01(term,R,T); % figure(3);imagesc(data_fit) % Visualization % pause (0.5) end tic v = Zernike_Fit(M,terms,R,T) toc assert(max(abs(v-z_fit))<0.01)

Attempt to execute SCRIPT zern_data_v01 as a function: /users/mss.system.4bohAI/zern_data_v01.m Error in Test2 (line 15) M = M + zern_data_v01(0,R,T); % Force NaN for non-data

3   Fail
M=zeros(128); terms=15; % Number of Terms to fit 0:terms-1 % Test Suite portion using zern_data_v01 [ ydim xdim ] = size(M); x = linspace(-1,1,xdim); y = linspace(1,-1,ydim); [X Y] = meshgrid(x,y); R = sqrt(X.^2 + Y.^2); T = atan2(Y,X); % Create surface z_fit= round(2*rand(terms,1)-1).*rand(terms,1); % Build a Surface M = M + zern_data_v01(0,R,T); % Force NaN for non-data M(M==0)=NaN; M(M>0)=0; for term = 0:terms-1 M = M + z_fit(term+1) * zern_data_v01(term,R,T); % figure(3);imagesc(data_fit) % Visualization % pause (0.5) end tic v = Zernike_Fit(M,terms,R,T) toc assert(max(abs(v-z_fit))<0.01)

Attempt to execute SCRIPT zern_data_v01 as a function: /users/mss.system.4bohAI/zern_data_v01.m Error in Test3 (line 15) M = M + zern_data_v01(0,R,T); % Force NaN for non-data