I am trying to generate a virual population simulation for my model using a uniform distribution for some parameter set from my simbiology model. Then I specify some if statements to reduce the simdata to fall within biological bounds and perform some calculations such as: mean, median, max, and min. Next, I would like to speicfy the cost funciton to optimize my model response with respect to the chosen parameter set. How can I correctly specify the cost function in terms of the simulaiton data? The cost functions is given as: and ; where l and u are lower and upper bounds for plausible ranges of model states. I've provided the simdataReduced and timeVector to help with solving the problem. How can I specify Mi(p) in this case? %% New script to perform analysis on the simdataReduced stopTime = simdataReduced(1).Time(end); timeVector = linspace(0,stopTime,700); simdataResampled = resample(simdataReduced, timeVector); % "Stack" the matrices of simulation results and average them % Calculate the 25th and 75th percentiles stackedData = cat(3, simdataResampled.Data); meanData = mean(stackedData, 3); maxData = max(stackedData, [],3); minData = min(stackedData, [],3); medianData= median(stackedData, 3); prc75= prctile(stackedData, 75, 3); prc25= prctile(stackedData, 25, 3); %%--------------- function script--------------------------------------------------- function J = computeCost(X, y, theta) %COMPUTECOST Compute cost for linear regression % J = COMPUTECOST(X, y, theta) computes the cost of using theta as the % parameter for linear regression to fit the data points in X and y % Initialize some useful values m = length(y); % number of training examples (length of simdataResampled) % You need to return the following variables correctly J = 0; % ====================== YOUR CODE HERE ====================== % Instructions: Compute the cost of a particular choice of theta % You should set J to the cost. prediction = X.*theta; %sqrError = (prediction - y).^2; c= 0.5*(lb+up) sqrError= (((prediction- c).^2) - (ub-c).^2); J = sum(max(sqrError), 0); % ========================================================================= end