Looking at your function, it looks like you are using the full square surface of the answer to make it fit. You can use the x2fx function to generate all terms. There is nothing revolutionary here, but it can be a little cleaner. You can also use it not only to install OLS, but also to use reliable methods. Here is the code I wrote:
% set up terms for the variables, linear, quadratic, interactive, and constant paramVEcomponents= x2fx([MAPkpa,RPM],'quadratic'); % robust fit using a Talwar weighting function [coefs,robuststats]= robustfit(paramVEcomponents(2:6),(CAM2.*TEMPd./MAPkpa),'talwar'); % generating points for all the data we have based on the new parameters of the response surface GMVEhat= paramVEcomponents * coefs;
source share