Daniel@0: function demprgp(action); Daniel@0: %DEMPRGP Demonstrate sampling from a Gaussian Process prior. Daniel@0: % Daniel@0: % Description Daniel@0: % This function plots the functions represented by a Gaussian Process Daniel@0: % model. The hyperparameter values can be adjusted on a linear scale Daniel@0: % using the sliders (though the exponential of the parameters is used Daniel@0: % in the covariance function), or by typing values into the text boxes Daniel@0: % and pressing the return key. Both types of covariance function are Daniel@0: % supported. An extra function specific parameter is needed for the Daniel@0: % rational quadratic function. Daniel@0: % Daniel@0: % See also Daniel@0: % GP Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: Daniel@0: if nargin<1, Daniel@0: action='initialize'; Daniel@0: end; Daniel@0: Daniel@0: if strcmp(action,'initialize') Daniel@0: Daniel@0: % Bounds on hyperparameter values Daniel@0: biasminval = -3.0; biasmaxval = 3.0; Daniel@0: noiseminval = -20; noisemaxval = -2; Daniel@0: fparminval = 0.0; fparmaxval = 2.0; Daniel@0: inwminval = 0; inwmaxval = 8; Daniel@0: % Initial hyperparameter values Daniel@0: bias = (biasminval+biasmaxval)/2; Daniel@0: noise = (noiseminval+noisemaxval)/2; Daniel@0: inweights = (inwminval+inwmaxval)/2; Daniel@0: fpar = (fparminval+fparmaxval)/2; Daniel@0: fpar2 = (fparminval+fparmaxval)/2; Daniel@0: Daniel@0: gptype = 'sqexp'; Daniel@0: Daniel@0: % Create FIGURE Daniel@0: fig=figure( ... Daniel@0: 'Name','Sampling from a Gaussian Process prior', ... Daniel@0: 'Position', [50 50 480 380], ... Daniel@0: 'NumberTitle','off', ... Daniel@0: 'Color', [0.8 0.8 0.8], ... Daniel@0: 'Visible','on'); Daniel@0: Daniel@0: % List box for covariance function type Daniel@0: nettype_box = uicontrol(fig, ... Daniel@0: 'Style', 'listbox', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'HorizontalAlignment', 'center', ... Daniel@0: 'Position', [0.52 0.77 0.40 0.12], ... Daniel@0: 'String', 'Squared Exponential|Rational Quadratic', ... Daniel@0: 'Max', 1, 'Min', 0, ... % Only allow one selection Daniel@0: 'Value', 1, ... % Initial value is squared exponential Daniel@0: 'BackgroundColor',[0.60 0.60 0.60],... Daniel@0: 'CallBack', 'demprgp GPtype'); Daniel@0: Daniel@0: % Title for list box Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [0.52 0.89 0.40 0.05], ... Daniel@0: 'String', 'Covariance Function Type', ... Daniel@0: 'BackgroundColor', get(fig, 'Color'), ... Daniel@0: 'HorizontalAlignment', 'center'); Daniel@0: Daniel@0: % Frames to enclose sliders Daniel@0: bottom_row = 0.04; Daniel@0: slider_frame_height = 0.15; Daniel@0: biasframe = uicontrol(fig, ... Daniel@0: 'Style', 'frame', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'String', 'bias', ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'Position', [0.05 bottom_row 0.35 slider_frame_height]); Daniel@0: Daniel@0: bpos = get(biasframe, 'Position'); Daniel@0: noise_frame_bottom = bpos(2) + bpos(4) + 0.02; Daniel@0: noiseframe = uicontrol(fig, ... Daniel@0: 'Style', 'frame', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.05 noise_frame_bottom 0.35 slider_frame_height]); Daniel@0: Daniel@0: npos = get(noiseframe, 'Position'); Daniel@0: inw_frame_bottom = npos(2) + npos(4) + 0.02; Daniel@0: inwframe = uicontrol(fig, ... Daniel@0: 'Style', 'frame', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.05 inw_frame_bottom 0.35 slider_frame_height]); Daniel@0: Daniel@0: inwpos = get(inwframe, 'Position'); Daniel@0: fpar_frame_bottom = inwpos(2) + inwpos(4) + 0.02; Daniel@0: % This frame sometimes has multiple parameters Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'frame', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.05 fpar_frame_bottom 0.35 2*slider_frame_height]); Daniel@0: Daniel@0: % Frame text Daniel@0: slider_text_height = 0.05; Daniel@0: slider_text_voffset = 0.08; Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.07 bottom_row+slider_text_voffset ... Daniel@0: 0.06 slider_text_height], ... Daniel@0: 'String', 'bias'); Daniel@0: Daniel@0: % Frame text Daniel@0: noiseframe = uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.07 noise_frame_bottom+slider_text_voffset ... Daniel@0: 0.08 slider_text_height], ... Daniel@0: 'String', 'noise'); Daniel@0: Daniel@0: % Frame text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.07 inw_frame_bottom+slider_text_voffset ... Daniel@0: 0.14 slider_text_height], ... Daniel@0: 'String', 'inweights'); Daniel@0: Daniel@0: % Frame text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.07 fpar_frame_bottom+slider_frame_height+ ... Daniel@0: slider_text_voffset 0.06 slider_text_height], ... Daniel@0: 'String', 'fpar'); Daniel@0: Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.07 fpar_frame_bottom+slider_text_voffset ... Daniel@0: 0.06 slider_text_height], ... Daniel@0: 'String', 'fpar2', ... Daniel@0: 'Tag', 'fpar2text', ... Daniel@0: 'Enable', 'off'); Daniel@0: Daniel@0: % Slider Daniel@0: slider_left = 0.07; Daniel@0: slider_width = 0.31; Daniel@0: slider_frame_voffset = 0.02; Daniel@0: biasslide = uicontrol(fig, ... Daniel@0: 'Style', 'slider', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Value', bias, ... Daniel@0: 'BackgroundColor', [0.8 0.8 0.8], ... Daniel@0: 'Position', [slider_left bottom_row+slider_frame_voffset ... Daniel@0: slider_width 0.05], ... Daniel@0: 'Min', biasminval, 'Max', biasmaxval, ... Daniel@0: 'Callback', 'demprgp update'); Daniel@0: Daniel@0: % Slider Daniel@0: noiseslide = uicontrol(fig, ... Daniel@0: 'Style', 'slider', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Value', noise, ... Daniel@0: 'BackgroundColor', [0.8 0.8 0.8], ... Daniel@0: 'Position', [slider_left noise_frame_bottom+slider_frame_voffset ... Daniel@0: slider_width 0.05], ... Daniel@0: 'Min', noiseminval, 'Max', noisemaxval, ... Daniel@0: 'Callback', 'demprgp update'); Daniel@0: Daniel@0: % Slider Daniel@0: inweightsslide = uicontrol(fig, ... Daniel@0: 'Style', 'slider', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Value', inweights, ... Daniel@0: 'BackgroundColor', [0.8 0.8 0.8], ... Daniel@0: 'Position', [slider_left inw_frame_bottom+slider_frame_voffset ... Daniel@0: slider_width 0.05], ... Daniel@0: 'Min', inwminval, 'Max', inwmaxval, ... Daniel@0: 'Callback', 'demprgp update'); Daniel@0: Daniel@0: % Slider Daniel@0: fparslide = uicontrol(fig, ... Daniel@0: 'Style', 'slider', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Value', fpar, ... Daniel@0: 'BackgroundColor', [0.8 0.8 0.8], ... Daniel@0: 'Position', [slider_left fpar_frame_bottom+slider_frame_height+ ... Daniel@0: slider_frame_voffset slider_width 0.05], ... Daniel@0: 'Min', fparminval, 'Max', fparmaxval, ... Daniel@0: 'Callback', 'demprgp update'); Daniel@0: Daniel@0: fpar2slide = uicontrol(fig, ... Daniel@0: 'Style', 'slider', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Value', fpar2, ... Daniel@0: 'BackgroundColor', [0.8 0.8 0.8], ... Daniel@0: 'Position', [slider_left fpar_frame_bottom+slider_frame_voffset ... Daniel@0: slider_width 0.05], ... Daniel@0: 'Min', fparminval, 'Max', fparmaxval, ... Daniel@0: 'Callback', 'demprgp update', ... Daniel@0: 'Tag', 'fpar2slider', ... Daniel@0: 'Enable', 'off'); Daniel@0: Daniel@0: % Text display of hyper-parameter values Daniel@0: Daniel@0: format = '%8f'; Daniel@0: Daniel@0: hp_left = 0.20; Daniel@0: hp_width = 0.17; Daniel@0: biasval = uicontrol(fig, ... Daniel@0: 'Style', 'edit', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [hp_left bottom_row+slider_text_voffset ... Daniel@0: hp_width slider_text_height], ... Daniel@0: 'String', sprintf(format, bias), ... Daniel@0: 'Callback', 'demprgp newval'); Daniel@0: Daniel@0: noiseval = uicontrol(fig, ... Daniel@0: 'Style', 'edit', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [hp_left noise_frame_bottom+slider_text_voffset ... Daniel@0: hp_width slider_text_height], ... Daniel@0: 'String', sprintf(format, noise), ... Daniel@0: 'Callback', 'demprgp newval'); Daniel@0: Daniel@0: inweightsval = uicontrol(fig, ... Daniel@0: 'Style', 'edit', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [hp_left inw_frame_bottom+slider_text_voffset ... Daniel@0: hp_width slider_text_height], ... Daniel@0: 'String', sprintf(format, inweights), ... Daniel@0: 'Callback', 'demprgp newval'); Daniel@0: Daniel@0: fparval = uicontrol(fig, ... Daniel@0: 'Style', 'edit', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [hp_left fpar_frame_bottom+slider_frame_height+ ... Daniel@0: slider_text_voffset hp_width slider_text_height], ... Daniel@0: 'String', sprintf(format, fpar), ... Daniel@0: 'Callback', 'demprgp newval'); Daniel@0: Daniel@0: fpar2val = uicontrol(fig, ... Daniel@0: 'Style', 'edit', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [hp_left fpar_frame_bottom+slider_text_voffset ... Daniel@0: hp_width slider_text_height], ... Daniel@0: 'String', sprintf(format, fpar), ... Daniel@0: 'Callback', 'demprgp newval', ... Daniel@0: 'Enable', 'off', ... Daniel@0: 'Tag', 'fpar2val'); Daniel@0: Daniel@0: Daniel@0: % The graph box Daniel@0: haxes = axes('Position', [0.5 0.28 0.45 0.45], ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Visible', 'on'); Daniel@0: Daniel@0: % The SAMPLE button Daniel@0: uicontrol(fig, ... Daniel@0: 'Style','push', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position',[0.5 bottom_row 0.13 0.1], ... Daniel@0: 'String','Sample', ... Daniel@0: 'Callback','demprgp replot'); Daniel@0: Daniel@0: % The CLOSE button Daniel@0: uicontrol(fig, ... Daniel@0: 'Style','push', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position',[0.82 bottom_row 0.13 0.1], ... Daniel@0: 'String','Close', ... Daniel@0: 'Callback','close(gcf)'); Daniel@0: Daniel@0: % The HELP button Daniel@0: uicontrol(fig, ... Daniel@0: 'Style','push', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position',[0.66 bottom_row 0.13 0.1], ... Daniel@0: 'String','Help', ... Daniel@0: 'Callback','demprgp help'); Daniel@0: Daniel@0: % Save handles to objects Daniel@0: Daniel@0: hndlList=[fig biasslide noiseslide inweightsslide fparslide ... Daniel@0: biasval noiseval inweightsval ... Daniel@0: fparval haxes nettype_box]; Daniel@0: set(fig, 'UserData', hndlList); Daniel@0: Daniel@0: demprgp('replot') Daniel@0: Daniel@0: Daniel@0: elseif strcmp(action, 'update'), Daniel@0: Daniel@0: % Update when a slider is moved. Daniel@0: Daniel@0: hndlList = get(gcf, 'UserData'); Daniel@0: biasslide = hndlList(2); Daniel@0: noiseslide = hndlList(3); Daniel@0: inweightsslide = hndlList(4); Daniel@0: fparslide = hndlList(5); Daniel@0: biasval = hndlList(6); Daniel@0: noiseval = hndlList(7); Daniel@0: inweightsval = hndlList(8); Daniel@0: fparval = hndlList(9); Daniel@0: haxes = hndlList(10); Daniel@0: nettype_box = hndlList(11); Daniel@0: Daniel@0: Daniel@0: bias = get(biasslide, 'Value'); Daniel@0: noise = get(noiseslide, 'Value'); Daniel@0: inweights = get(inweightsslide, 'Value'); Daniel@0: fpar = get(fparslide, 'Value'); Daniel@0: fpar2 = get(findobj('Tag', 'fpar2slider'), 'Value'); Daniel@0: Daniel@0: format = '%8f'; Daniel@0: set(biasval, 'String', sprintf(format, bias)); Daniel@0: set(noiseval, 'String', sprintf(format, noise)); Daniel@0: set(inweightsval, 'String', sprintf(format, inweights)); Daniel@0: set(fparval, 'String', sprintf(format, fpar)); Daniel@0: set(findobj('Tag', 'fpar2val'), 'String', ... Daniel@0: sprintf(format, fpar2)); Daniel@0: Daniel@0: demprgp('replot'); Daniel@0: Daniel@0: elseif strcmp(action, 'newval'), Daniel@0: Daniel@0: % Update when text is changed. Daniel@0: Daniel@0: hndlList = get(gcf, 'UserData'); Daniel@0: biasslide = hndlList(2); Daniel@0: noiseslide = hndlList(3); Daniel@0: inweightsslide = hndlList(4); Daniel@0: fparslide = hndlList(5); Daniel@0: biasval = hndlList(6); Daniel@0: noiseval = hndlList(7); Daniel@0: inweightsval = hndlList(8); Daniel@0: fparval = hndlList(9); Daniel@0: haxes = hndlList(10); Daniel@0: Daniel@0: bias = sscanf(get(biasval, 'String'), '%f'); Daniel@0: noise = sscanf(get(noiseval, 'String'), '%f'); Daniel@0: inweights = sscanf(get(inweightsval, 'String'), '%f'); Daniel@0: fpar = sscanf(get(fparval, 'String'), '%f'); Daniel@0: fpar2 = sscanf(get(findobj('Tag', 'fpar2val'), 'String'), '%f'); Daniel@0: Daniel@0: set(biasslide, 'Value', bias); Daniel@0: set(noiseslide, 'Value', noise); Daniel@0: set(inweightsslide, 'Value', inweights); Daniel@0: set(fparslide, 'Value', fpar); Daniel@0: set(findobj('Tag', 'fpar2slider'), 'Value', fpar2); Daniel@0: Daniel@0: demprgp('replot'); Daniel@0: Daniel@0: elseif strcmp(action, 'GPtype') Daniel@0: hndlList = get(gcf, 'UserData'); Daniel@0: nettype_box = hndlList(11); Daniel@0: gptval = get(nettype_box, 'Value'); Daniel@0: if gptval == 1 Daniel@0: % Squared exponential, so turn off fpar2 Daniel@0: set(findobj('Tag', 'fpar2text'), 'Enable', 'off'); Daniel@0: set(findobj('Tag', 'fpar2slider'), 'Enable', 'off'); Daniel@0: set(findobj('Tag', 'fpar2val'), 'Enable', 'off'); Daniel@0: else Daniel@0: % Rational quadratic, so turn on fpar2 Daniel@0: set(findobj('Tag', 'fpar2text'), 'Enable', 'on'); Daniel@0: set(findobj('Tag', 'fpar2slider'), 'Enable', 'on'); Daniel@0: set(findobj('Tag', 'fpar2val'), 'Enable', 'on'); Daniel@0: end Daniel@0: demprgp('replot'); Daniel@0: Daniel@0: elseif strcmp(action, 'replot'), Daniel@0: Daniel@0: % Re-sample from the prior and plot graphs. Daniel@0: Daniel@0: oldFigNumber=watchon; Daniel@0: Daniel@0: hndlList = get(gcf, 'UserData'); Daniel@0: biasslide = hndlList(2); Daniel@0: noiseslide = hndlList(3); Daniel@0: inweightsslide = hndlList(4); Daniel@0: fparslide = hndlList(5); Daniel@0: haxes = hndlList(10); Daniel@0: nettype_box = hndlList(11); Daniel@0: gptval = get(nettype_box, 'Value'); Daniel@0: if gptval == 1 Daniel@0: gptype = 'sqexp'; Daniel@0: else Daniel@0: gptype = 'ratquad'; Daniel@0: end Daniel@0: Daniel@0: bias = get(biasslide, 'Value'); Daniel@0: noise = get(noiseslide, 'Value'); Daniel@0: inweights = get(inweightsslide, 'Value'); Daniel@0: fpar = get(fparslide, 'Value'); Daniel@0: Daniel@0: Daniel@0: axes(haxes); Daniel@0: cla Daniel@0: set(gca, ... Daniel@0: 'Box', 'on', ... Daniel@0: 'Color', [0 0 0], ... Daniel@0: 'XColor', [0 0 0], ... Daniel@0: 'YColor', [0 0 0], ... Daniel@0: 'FontSize', 14); Daniel@0: ymin = -10; Daniel@0: ymax = 10; Daniel@0: axis([-1 1 ymin ymax]); Daniel@0: set(gca,'DefaultLineLineWidth', 2); Daniel@0: Daniel@0: xvals = (-1:0.01:1)'; Daniel@0: nsample = 10; % Number of samples from prior. Daniel@0: hold on Daniel@0: plot([-1 0; 1 0], [0 ymin; 0 ymax], 'b--'); Daniel@0: net = gp(1, gptype); Daniel@0: net.bias = bias; Daniel@0: net.noise = noise; Daniel@0: net.inweights = inweights; Daniel@0: if strcmp(gptype, 'sqexp') Daniel@0: net.fpar = fpar; Daniel@0: else Daniel@0: fpar2 = get(findobj('Tag', 'fpar2slider'), 'Value'); Daniel@0: net.fpar = [fpar fpar2]; Daniel@0: end Daniel@0: cn = gpcovar(net, xvals); Daniel@0: cninv = inv(cn); Daniel@0: cnchol = chol(cn); Daniel@0: set(gca, 'DefaultLineLineWidth', 1); Daniel@0: for n = 1:nsample Daniel@0: y = (cnchol') * randn(size(xvals)); Daniel@0: plot(xvals, y, 'y'); Daniel@0: end Daniel@0: Daniel@0: watchoff(oldFigNumber); Daniel@0: Daniel@0: elseif strcmp(action, 'help'), Daniel@0: Daniel@0: % Provide help to user. Daniel@0: Daniel@0: oldFigNumber=watchon; Daniel@0: Daniel@0: helpfig = figure('Position', [100 100 480 400], ... Daniel@0: 'Name', 'Help', ... Daniel@0: 'NumberTitle', 'off', ... Daniel@0: 'Color', [0.8 0.8 0.8], ... Daniel@0: 'Visible','on'); Daniel@0: Daniel@0: % The HELP TITLE BAR frame Daniel@0: uicontrol(helpfig, ... Daniel@0: 'Style','frame', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'HorizontalAlignment', 'center', ... Daniel@0: 'Position', [0.05 0.82 0.9 0.1], ... Daniel@0: 'BackgroundColor',[0.60 0.60 0.60]); Daniel@0: Daniel@0: % The HELP TITLE BAR text Daniel@0: uicontrol(helpfig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position', [0.26 0.85 0.6 0.05], ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'String', 'Help: Sampling from a Gaussian Process Prior'); Daniel@0: Daniel@0: helpstr1 = strcat(... Daniel@0: 'This demonstration shows the effects of sampling from a Gaussian', ... Daniel@0: ' process prior. The parameters bias, noise, inweights and fpar', ... Daniel@0: ' control the corresponding terms in the covariance function of the',... Daniel@0: ' Gaussian process. Their values can be adjusted on a linear scale',... Daniel@0: ' using the sliders, or by typing values into the text boxes and',... Daniel@0: ' pressing the return key. After setting these values, press the',... Daniel@0: ' ''Sample'' button to see a new sample from the prior.'); Daniel@0: Daniel@0: helpstr2 = strcat(... Daniel@0: 'Observe how inweights controls horizontal length-scale of the',... Daniel@0: ' variation in the functions, noise controls the roughness of the',... Daniel@0: ' functions, and the bias controls the size of the', ... Daniel@0: ' vertical offset of the signal.'); Daniel@0: helpstr3 = strcat(... Daniel@0: 'There are two types of covariance function supported by', ... Daniel@0: ' Netlab which can be selected using the ''Covariance Function', ... Daniel@0: ' Type'' menu.'); Daniel@0: helpstr4 = strcat(... Daniel@0: 'The squared exponential has a single fpar which', ... Daniel@0: ' controls the vertical scale of the process.'); Daniel@0: helpstr5 = strcat(... Daniel@0: 'The rational quadratic has two fpar values. The first is', ... Daniel@0: ' is a scale parameter inside the rational function like the',... Daniel@0: ' first fpar for the squared exponential covariance, while the', ... Daniel@0: ' second gives the exponent of the rational function (i.e. the',... Daniel@0: ' rate of decay of the covariance function.'); Daniel@0: % Set up cell array with help strings Daniel@0: hstr(1) = {helpstr1}; Daniel@0: hstr(2) = {''}; Daniel@0: hstr(3) = {helpstr2}; Daniel@0: hstr(4) = {''}; Daniel@0: hstr(5) = {helpstr3}; Daniel@0: hstr(6) = {''}; Daniel@0: hstr(7) = {helpstr4}; Daniel@0: hstr(8) = {''}; Daniel@0: hstr(9) = {helpstr5}; Daniel@0: Daniel@0: % The HELP text Daniel@0: helpui = uicontrol(helpfig, ... Daniel@0: 'Style', 'Text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'ForegroundColor', [0 0 0], ... Daniel@0: 'HorizontalAlignment', 'left', ... Daniel@0: 'BackgroundColor', [1 1 1], ... Daniel@0: 'Min', 0, ... Daniel@0: 'Max', 2, ... Daniel@0: 'Position', [0.05 0.2 0.9 0.57]); Daniel@0: [hstrw, newpos] = textwrap(helpui, hstr); Daniel@0: set(helpui, 'String', hstrw, 'Position', [0.05, 0.2, 0.9 newpos(4)]); Daniel@0: Daniel@0: % The CLOSE button Daniel@0: uicontrol(helpfig, ... Daniel@0: 'Style','push', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'BackgroundColor', [0.6 0.6 0.6], ... Daniel@0: 'Position',[0.4 0.05 0.2 0.1], ... Daniel@0: 'String','Close', ... Daniel@0: 'Callback','close(gcf)'); Daniel@0: Daniel@0: watchoff(oldFigNumber); Daniel@0: Daniel@0: end; Daniel@0: