Cody

Solution 152449

Submitted on 21 Oct 2012 by Richard Zapor
  • Size: 61
  • 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
urlwrite('http://tinyurl.com/matlab-zernike','zern_data_v01.m') rehash path % z = zern_data_v01(j,r,t) % is sufficient in the main routine
ans = /users/msssystem17/zern_data_v01.m [Warning: Function /opt/mlsedu/mdcsserver/latest/m/web_common/shadow/license.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 189 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/web_common/shadow/graphicsAndGuis/uicontrol.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 189 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/home.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 189 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/keyboard.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 189 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/more.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 189 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/pause.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 189 In verifyCode at 40 In fevalJSON at 14]
2   Pass
%% 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))
ans = 0.0000 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 v = 0.0000 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 Elapsed time is 0.098459 seconds.
3   Pass
%% 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)
ans = -0.4359 -0.0000 -0.3063 0.0000 0.0000 0.8176 -0.7948 0.6443 0.3786 -0.0000 v = -0.4359 -0.0000 -0.3063 0.0000 0.0000 0.8176 -0.7948 0.6443 0.3786 -0.0000 Elapsed time is 0.143919 seconds.
4   Pass
%% 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)
ans = -0.0000 -0.0000 0.3111 0.9234 -0.0000 -0.0000 -0.0000 -0.9797 0.0000 -0.0000 -0.2581 0.4087 -0.5949 -0.2622 -0.6028 v = -0.0000 -0.0000 0.3111 0.9234 -0.0000 -0.0000 -0.0000 -0.9797 0.0000 -0.0000 -0.2581 0.4087 -0.5949 -0.2622 -0.6028 Elapsed time is 0.065641 seconds.