How to create a higher resolution data?

4 次查看(过去 30 天)
Mr. 206
Mr. 206 2018-11-22
评论: Mr. 206 2018-11-22
I am creating a series of data (delta), which i am giving input to a process to find out for which delta the process yields a minimum results. But the problem is my 'delta' are linear spaced data. and for better results i have to increase the number of delta which is making my code very slow.
Is there any way i can generate better resolution of data for delta so that i don't need to increase the steps and would get better result?
Here is my code for generating delta which i am later feeding in the for loop of a process.
delta = linspace(-delta_range,delta_range,23); %For better results i have to increase this number about 300
shifting_steps = numel(delta); %so the shifting steps increased
delta_sequence = numel(delta);
for delta_loop = 1:1: delta_sequence % forloop of the process to check which delta is giving minumum output
.....
....
process
end
  2 个评论
madhan ravi
madhan ravi 2018-11-22
That depends on what process you are doing , why not post it?
Mr. 206
Mr. 206 2018-11-22
The process is very large and won't help. But if you are interested i can post.
The thing is in this case i am getting 11 negative delta and 11 positive delta and a 0. but the frequency are not high. I want to have low shifting_steps but higher frequncy.
And here is my process...
d0_L2_post = nan(Model_number,shifting_steps);
d1_L2_post = nan(Model_number,shifting_steps);
d0_p_post = nan(Model_number,shifting_steps);
d1_p_post = nan(Model_number,shifting_steps);
delta_sequence = numel(delta);
for delta_loop = 1:1: delta_sequence
x_0_f_shifted = x_0_f .-delta(:,delta_loop);
%Sorting the x column vector in ascending order
if ~issorted(x_0_f_shifted)
[x_sorted_f_shifted, sorting_index]=sort(x_0_f_shifted);
y_sorted_f=y_0_f(sorting_index);
else
x_sorted_f_shifted=x_0_f_shifted;
end
%Taking the first and last element of the x_sorted column vector as range with an allowance of 0.1
a_f_shifted=x_sorted_f_shifted(1,1);
b_f_shifted=x_sorted_f_shifted(end,1);
xh_f_shifted=linspace(a_f_shifted,b_f_shifted,150);
%xhat takes only column vector
xz_f_shifted=xh_f_shifted';
y_0_diff=gradient(y_0_f,x_0_f_shifted);
[f_shifted, lambda] = smooth (x_0_f_shifted, y_0_f,"d",3,"lguess",1e-4,"xhat", xz_f_shifted);
[f_diff_shifted, lambda] = smooth (x_0_f_shifted, y_0_diff,"d",2,"lguess",1e-4,"xhat", xz_f_shifted);
cc = 0;
%This lopp will take column 1,3,5,7...............
for jj = 3: 2 : size(READ,2)
cc = cc+1;
xg_extracted_new = READ(:,jj);
yg_extracted_new = READ(:,jj+1);
%Restricting the values to be within Experimental range
xg_index_new = (xg_extracted_new >= min(x_0_f_shifted)) & (xg_extracted_new <= max(x_0_f_shifted)); % Logical Vector
xg_new = xg_extracted_new (xg_index_new);
yg_new = yg_extracted_new (xg_index_new);
%excluding all the 911 values from the columns
A = 911911911;
x_0_g_new = xg_new(find(xg_new~=A));
y_0_g_new = yg_new(find(yg_new~=A));
%Sorting the x column vector in ascending order
if ~issorted(x_0_g_new)
[x_sorted_g_new, sorting_index]=sort(x_0_g_new);
y_sorted_g_new=y_0_g_new(sorting_index);
else
x_sorted_g_new=x_0_g_new;
end
y_0_g_diff_new=gradient(y_0_g_new,x_0_g_new);
%Differentiating the Experimental graph and Model graph
[g_new, lambda] = regdatasmooth (x_0_g_new, y_0_g_new,"d",3,"lguess",1e-4,"xhat", xz_f_shifted);
[g_diff_new, lambda] = regdatasmooth (x_0_g_new, y_0_g_diff_new,"d",3,"lguess",1e-4,"xhat", xz_f_shifted);
%-----------------------------d0_p_pearson----------------------------------------
format long
normalized_f_shifted = f_shifted/norm(f_shifted);
normalized_g_new = g_new/norm(g_new);
dot_product_fg_shifted = dot(normalized_f_shifted,normalized_g_new);
norm_product_fg_shifted = (norm(normalized_f_shifted)*norm(normalized_g_new));
pearson_0_similarities_fg_shifted = (dot_product_fg_shifted./(norm_product_fg_shifted));
phase_shift_radians_fg_shifted = acos(pearson_0_similarities_fg_shifted);
d0_p_post(cc,delta_loop) = sqrt((1-pearson_0_similarities_fg_shifted))/2;
%-----------------------------d1_p_pearson----------------------------------------
dot_product_fg_diff_shifted = dot(f_diff_shifted,g_diff_new);
norm_product_fg_diff_shifted = (norm(f_diff_shifted)*norm(g_diff_new));
pearson_1_similarities_fg_diff_shifted = (dot_product_fg_diff_shifted/norm_product_fg_diff_shifted);
phase_shift_radians_fg_diff_shifted = acos(pearson_1_similarities_fg_diff_shifted);
d1_p_post(cc,delta_loop) = sqrt((1-pearson_1_similarities_fg_diff_shifted))/2;
%-----------------------------d0_L2_Euclidean----------------------------------------
Rescaled_f_shifted = f_shifted/max(f_shifted);
Rescaled_g_new = g_new/max(f_shifted);
Model_number = (size(READ,2)/2)-1;
D = min(max(x_0_f_shifted),max(xg_extracted)) - max(min(x_0_f_shifted),min(xg_extracted));
Difference_Rescaled_fg_shifted = (Rescaled_f_shifted.-Rescaled_g_new);
d0_L2_post (cc,delta_loop) = norm(Difference_Rescaled_fg_shifted)/(abs(D)*Model_number);
%-----------------------------d1_L2_Euclidean----------------------------------------
Rescaled_f_diff_shifted = f_diff_shifted/max(f_diff_shifted);
Rescaled_g_diff_new = g_diff_new/max(f_diff_shifted);
Difference_Rescaled_fg_diff_shifted = (Rescaled_f_diff_shifted.-Rescaled_g_diff_new);
d1_L2_post(cc,delta_loop) = norm(Difference_Rescaled_fg_diff_shifted)/(abs(D)*Model_number);
end
end
[d0_p_post, idx_d0_p_post] = min(d0_p_post, [], 2);
d0_p_shift = abs(delta(idx_d0_p_post)./Experimental_range)';
[d1_p_post, idx_d1_p_post] = min(d1_p_post, [], 2);
d1_p_shift =abs(delta(idx_d1_p_post)./Experimental_range)';
[d0_L2_post, idx_d0_L2_post] = min(d0_L2_post, [], 2);
d0_L2_shift=abs(delta(idx_d0_L2_post)./Experimental_range)';
[d1_L2_post, idx_d1_L2_post] = min(d1_L2_post, [], 2);
d1_L2_shift = abs(delta(idx_d1_L2_post)./Experimental_range)';

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by