我正在编写一个代码来实现一个基本的优化方法,以保持观察到的和模拟的配置文件之间的最小误差。我这样做是因为简单的均方根误差。我在这里给出的整个代码都是为了让人知道。
%% Vegetation profile along a hillslope
% Parameters
Tv = 1; % values are {1,2,3,5,10}
%Kvg = 0.3; % according to the Tv values Kvg=1/Tv
Kvg = 1/Tv;
Kvd = 0.5; % valuse are {0.1,0.5,1,5,10}
Tcv = 10; % values are {20,50,80,130,180}
q = (1/3);
Nv = (1:1:10); %(Kvd*Tcv)/Kvg; range is given for the parameter
m = 2/3;
n = 2/3;
%% Horizontal coordinate and length scale
x = 0:1:100;
L = 100;
x_non = x/L;
Ne =10; %L/Tcv;
%% Vegetation profile on the slope
v = zeros(length(x_non),length(Nv));
for i = 1:length(x_non)
for j = 1:length(Nv)
v(i,j) = (1/(1+Nv(j)*(Ne^q)*(x_non(i)^q)));
end
end
%% importing the excel file containg real dataset
obs_data = xlsread('model_data.xlsx'); % 1-distance, 2-elevation, 3- vegetation, 4-slope
%% root mean square error between real and synthetic dataset of vegetation
rmse_v = zeros(length(x_non),length(Nv));
err_v = zeros(1,length(Nv));
for j=1:length(Nv)
rmse_v(:,j)=(obs_data(:,3)-v(:,j)).^2;
err_v(1,j)= sqrt(mean(rmse_v(:,j)));
end
现在我必须提取rmse_v最小的Nv值。上述陈述为真的Nv值必须在下一个会话中使用。
Nt = (1:1:100);
% Slope profile on the x direction
s = zeros(length(x_non),length(Nt));
for i = 1:length(x_non)
for j = 1:length(Nt)
s(i,j)=((Ne^q)/Nt(j))*(x_non(i)^(q-m))+(1/(Nt(j)*(x_non(i)^m)*(1+Nv*(Ne^q)...
*(x_non(i)^q))))^(1/n);
end
end
我将非常感激能够找到完成特定事情的方式。
谢谢。 此致