# matlab代做/代写/参数估计/最小二乘法/微分方程求解/算法设计

function [Mode, Number_values] = M_shift2 (Values, Window_radius, Initial, Mv)
% assumes that Values contains cumulative information, i.e.
% the number of elements of the particular value in each Values cell

Current_val = round(Initial+2);
Next_val = round(Initial);
L1 = size(Values, 1);  L2 = size(Values, 2);

% global plot_number plot_xmin plot_xmax plot_ymin plot_ymax
% if plot_number == 1
% figure;
% end
% [II, JJ] = find(Values > 0);
% if plot_number == 1
% end

% subplot(2, 2, plot_number);
% plot(II, JJ, '.');
% xlabel('first principal component');
% ylabel('second prrincipal component');
% axis([plot_xmin plot_xmax plot_ymin plot_ymax])

while norm(Next_val-Current_val) > 2

Current_val = Next_val;
clear x;
Window = Values(...
[x(1, :, :), x(2, :, :)] = ...
ndgrid(...

for i=1:2
Sum_values(1, i) = sum(sum(squeeze(x(i, :, :)) .* Window));
end
Number_values = sum(sum(Window));

if Number_values < Mv
Mode = Initial;
Number_values = 0;
return;
end

Next_val = round(Sum_values/Number_values);
end
Mode = Next_val;

% plot_number = plot_number+1;