# Goal seek two variables with unusual function (contains summation and data-dependent)

1 view (last 30 days)
Abdul Kadir Alhamid on 10 Aug 2020
Hi there!
I think I have a bit simple and interesting question but might take a while to look at the code below. I am doing a regression using RBF neural network. I have to change the r_slr and r_depth variable accordingly so that the root mean square error between the data and the regression estimation is 0. Is there any way to make a 'goalseek' as in excel for these two variables and for such unusual 3D function below? The function depends on the data by the way, x and y is the input and z is the output.
x_data=x_data'; %1600 x 1 double, given data input
y_data=y_data'; %1600 x 1 double, given data input
z_data=z_data'; %1600 x 1 double, given data output
phi=zeros(size(x_data,1),size(y_data,1)); %1600 x 1600 double
r_slr=0.9222; %Shape parameter in x, object of interest, want to adjust this
r_depth=2.0417; %Shape parameter in y, want to adjust this as well
%Making phi matrix
for i=1:size(phi,1)
for j=1:size(phi,2)
phi(i,j)=exp(-((1/(r_slr.^2)).*abs(x_data(i)-x_data(j)).^2)-((1/(r_depth.^2)).*abs(y_data(i)-y_data(j)).^2));
end
end
%Making w array
w=(phi*phi')\phi'*z_data; %1600 x 1 double
x_est=x_data; %since this is input, so it's the same
y_est=y_data; %this is the same as well
z_est=zeros(size(z_data,1),1);
%below is the function
for i=1:size(z,1)
z_est(i)=sum(w.*exp(-((1/(r_slr.^2)).*abs(x_data-x_est(i)).^2)-((1/(r_depth.^2)).*abs(y_data-y_est(i)).^2)));
end
%the function above depends on x_data and y_data, also has a summation for every point of estimation.
RMSE = sqrt(mean((z_data - z_est).^2)); %the goal is to make this as minimum as possible (0 if possible)
Thank you
Abdul