SLIDE 5 % Show Side -by -Side Views of the Surface % ============================================================================== % yTestSquare = reshape(yTest ,nSide ,nSide ); % surf(x1Sweep ,x2Sweep , yTestSquare ); figure; FigureSet (1 ,4 ,4); colormap(pink (256)); h = surf(x1Side ,x2Side , yTestBlock ); set(h,’LineWidth ’,0.1); hold on; h = plot3(xBuild (:,1), xBuild (:,2), yBuild ,’g.’); set(h,’MarkerSize ’ ,12); hold
set(gca ,’Position ’ ,[0.13 0.13 0.85 0.85 ]); xlim ([-1.5 1.5 ]); ylim ([-1.5 1.5 ]); zlim ([-1.0 1.0 ]); caxis ([-3 1]); xlabel(’x1 ’,’Interpreter ’,’LaTeX ’); ylabel(’x2 ’,’Interpreter ’,’LaTeX ’); zlabel(’g(x1, x2)’,’Interpreter ’,’LaTeX ’); box off; axis square grid on; AxisSet; fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ newslide\n’); fprintf(fileIdentifier ,’\\ slideheading{ Example \\ arabic{exc }: Ramp Hill Surface Plot }\n’); fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ begin{center }\n’);
Portland State University ECE 4/557 Nonlinear Modeling
19
for c1=1: nDataSetsBuild DataSetsBuild (c1).x = 0.6*randn(nPointsBuild ,2); DataSetsBuild (c1).y = CreateDataSet ( DataSetsBuild (c1).x ,’function ’,’RampHill ’,’NoisePower ’,noisePower ); end yTest = CreateDataSet (xTest ,’function ’,’RampHill ’); nPointsTest = length(yTest ); save(’RampHill ’,’DataSetsBuild ’,’xTest ’,’yTest ’,’nPointsSide ’,’x1Side ’,’x2Side ’); yTestBlock = reshape(yTest ,nPointsSide , nPointsSide ); xBuild = DataSetsBuild (1) .x; yBuild = DataSetsBuild (1) .y; % ============================================================================== % Write Table Summarizing Properties % ============================================================================== fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ newslide\n’); fprintf(fileIdentifier ,’\\ stepcounter{exc }\n’); fprintf(fileIdentifier ,’\\ slideheading{ Example \\ arabic{exc }: Ramp Hill }\n’); fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ begin{bulleted }\n’); fprintf(fileIdentifier ,’\t\\ item Number of points per (training/ estimation) data set: %d \n’,nPointsBuild ); fprintf(fileIdentifier ,’\t\\ item Number of evaluation points (test/ evaluation) data set: %d \n’,nPointsTest fprintf(fileIdentifier ,’\t\\ item Noise power: %4 .2f \n’,noisePower ); fprintf(fileIdentifier ,’\t\\ item Signal (g(Bx)) power: %4 .2f \n’,var(yTest )); fprintf(fileIdentifier ,’\t\\ item Signal -to -noise ratio (SNR ): %4 .2f \n’,var(yTest )/ noisePower ); fprintf(fileIdentifier ,’\t\\ item Number of data sets: %d \n’,nDataSetsBuild ); fprintf(fileIdentifier ,’\\end{bulleted }\n’); fprintf(fileIdentifier ,’\n’);
Portland State University ECE 4/557 Nonlinear Modeling
17
for c1 =1:2 switch c1 case 1, view (46 ,12); case 2 view ( -71 ,12); end fileName = sprintf(’%s-%s%d’,functionName ,’SurfacePlot ’,c1); print(fileName ,’-depsc ’); fprintf(fileIdentifier ,’\t\\ includegraphics [ width =0 .48 \\ columnwidth ]{ Matlab /%s} ’,fileName ); if c1==1, fprintf(fileIdentifier ,’\\ hfill \n’); else fprintf(fileIdentifier ,’\n’); end; end fprintf(fileIdentifier ,’\\end{center }\n’); fprintf(fileIdentifier ,’\n’); % ============================================================================== % List the MATLAB Code % ============================================================================== fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ newslide \n’); fprintf(fileIdentifier ,’\\ slideheading{ Example \\ arabic{exc }: MATLAB Code }\n’); fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\t \\ matlabcode{Matlab /% s.m }\n’,functionName ); fprintf(fileIdentifier ,’\n’); % ============================================================================== % Close the File % ============================================================================== fclose( fileIdentifier );
Portland State University ECE 4/557 Nonlinear Modeling
20
% ============================================================================== % Show A 2D Scatter of a Typical Build Data Set % ============================================================================== figure; FigureSet (1,’Slides ’); contour(x1Side ,x2Side ,yTestBlock ,25); hold on; h = scatter(xBuild (:,1), xBuild (:,2),5, yBuild ,’filled ’); set(h,’LineWidth ’,0.2); set(h,’MarkerEdgeColor ’,’k’) hold
axis ([-1.5 1.5
axis(’square ’) FigureLatex; xlabel(’x1 ’); ylabel(’x2 ’); zlabel(sprintf(’No. Build Points: %4.0f ’,nPointsBuild )); AxisSet (8); fileName = sprintf(’%s-%s’,functionName ,’Contour ’); print(fileName ,’-depsc ’); fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ newslide\n’); fprintf(fileIdentifier ,’\\ slideheading{ Example \\ arabic{exc }: Ramp Hill }\n’); fprintf(fileIdentifier ,’%%==============================================================================\ n’ fprintf(fileIdentifier ,’\\ begin{center }\n’); fprintf(fileIdentifier ,’\t\\ includegraphics [ scale =1]{ Matlab /%s}\n’,fileName ); fprintf(fileIdentifier ,’\\end{center }\n’); fprintf(fileIdentifier ,’\n’); % ==============================================================================
Portland State University ECE 4/557 Nonlinear Modeling
18