Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1: Create a graphical user interface that allows the user to define a ro

ID: 3672291 • Letter: P

Question

Problem 1: Create a graphical user interface that allows the user to define a row vector x = [xmin:xstep:xmax], by entering the values of xmin, xstep and xmax. It also should be possible to define a trigonometric Matlab function (call it theFunction), by entering its name as a string. As soon as a set of valid inputs is provided, your program should create row vector x, compute f(x) = theFunction(x) and plot f(x) over x.

Explanation / Answer

function [SVR] = BuildPlot (SVR, ShowAxis) % Parameters nx = 100; ngrid = 2*nx+1; bandwidth = 50; borderwidth = 50; % Compute the grid clear figures; if (SVR.SamplesTrainedNumber>0) xmin = min(min(SVR.X),[],1); xmax = max(max(SVR.X),[],1); if (xmin==xmax) xmin = xmin-1; xmax = xmax+1; end xmin = floor(xmin); xmax = ceil(xmax); xstep = (xmax-xmin)/(ngrid-1); xmax = xmax+borderwidth*xstep; xmin = xmin-borderwidth*xstep; else xmin = -1; xmax = 1; xstep = (xmax-xmin)/(ngrid-1); end xgrid = (xmin:xstep:xmax)'; ygrid = Predict(SVR, xgrid); if (SVR.SamplesTrainedNumber>0) ymin = min([ygrid; SVR.Y],[],1); ymax = max([ygrid; SVR.Y],[],1); if (ymax-ymin