sum y-values where they do overlap of different x- and y-vectors
Show older comments
What kind of different ways are available to sum up the y-values where the different y-values do overlap each other (see plot(x1,y1,x2,y2)). The problem is here that the x-vectors doesn't have the same starting point. This example script below is a simplified script of the file with 24 different x-vectors (see further below).
%%simplified example
x1 = 250:260;
y1 = [0 0.2 0.3 0.5 0.55 0.6 0.55 0.5 0.3 0.2 0 ];
x2 = 255:265;
y2 = y1*0.8;
figure; plot(x1,y1,x2,y2)
%%script with 24 different x-vectors
sigma = 1;
step=0.01;
min = -10;
max = 10;
%%v',v'' = 0,4 - 0,5 - 1,4 - 3,13
FCF_A3_X1 = [ .1408e-0 .1854e-0 .1106e-0 .1170e-0 ];
x0_A3_X1 = [ 246.3 260.5 237.9 385.7 ];
%%v',v''_ = 0,0 - 0,1 - 1,5 - 2,1 - 2,6 - 2,7 - 3,1 - 3,6 - 4,7
FCF_C3_B3 = [ .4527e-0 .3291e-0 .4663e-1 .3413e-0 .7913e-1 .3622e-1 .2536e-0 .1292e-0 .1000e-0];
x0_C3_B3 = [ 337.0 357.6 426.8 313.5 420.0 448.9 296.1 389.4 385.6];
%%v',v'' = 2,0 - 3,0 - 5,0 - 5,1 - 6,3 - 7,5 - 8,6 - 9,5 - 9,6 - 10,6 - 12,7
FCF_B3_A3 = [ .1617e-0 .3423e-1 .2680e-3 .1640e-1 .2311e-0 .7415e-1 .1991e-1 .1564e-0 .2493e-0 .1990e-0 .7324e-1];
x0_B3_A3 = [ 773.2 685.8 562.2 611.4 660.8 714.7 704.2 589.4 638.0 584.3 536.3];
figure
for i=1:length(x0_A3_X1);
x_A3_X1(i,:) = x0_A3_X1(i)+min :step: x0_A3_X1(i)+max;
f_A3_X1(i,:) = exp(-(x_A3_X1(i,:)-x0_A3_X1(i)).^2./(2*sigma^2));
f_cor1(i,:) = f_A3_X1(i,:)*FCF_A3_X1(i);
for j=1:length(x0_C3_B3);
x_C3_B3(j,:) = x0_C3_B3(j)+min :step: x0_C3_B3(j)+max;
f_C3_B3(j,:) = exp(-(x_C3_B3(j,:)-x0_C3_B3(j)).^2./(2*sigma^2));
f_cor2(j,:) = f_C3_B3(j,:)*FCF_C3_B3(j);
for k=1:length(x0_B3_A3);
x_B3_A3(k,:) = x0_B3_A3(k)+min :step: x0_B3_A3(k)+max;
f_B3_A3(k,:) = exp(-(x_B3_A3(k,:)-x0_B3_A3(k)).^2./(2*sigma^2));
f_cor3(k,:) = f_B3_A3(k,:)*FCF_B3_A3(k);
plot(x_A3_X1(i,:),f_cor1(i,:),x_C3_B3(j,:),f_cor2(j,:),x_B3_A3(k,:),f_cor3(k,:));
hold on
%pause(0.2)
end
end
end
1 Comment
Richa Gupta
on 7 Aug 2015
Edited: Richa Gupta
on 7 Aug 2015
Can you explain how is x-vectors not having the same starting point related to summing up the y-values?
Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!