MATLAB: Plotting two vectors/arrays/curves with different distribution intervals as a single curve

plot

Suppose that I'd like to plot y1+y2 against x for the interval of [120,480]
x y1 x y2
24 1.4050 15 9.4526
48 0.8348 30 7.7970
72 1.0272 45 6.8056
96 1.2513 60 6.0248
120 1.5518 75 5.3847
144 2.1398 90 5.1452
168 3.2061 105 4.7522
192 3.6026 120 4.4740
216 3.0298 135 4.2774
240 1.9868 150 4.1293
264 1.4370 165 4.1693
288 1.1396 180 4.0630
312 0.9630 195 4.1130
336 0.9592 210 4.1511
360 0.8783 225 3.8805
384 0.8384 240 3.7559
408 0.8365 255 3.3221
432 0.8786 270 2.9122
456 1.0791 285 2.5477
480 1.2648 300 2.2394
504 1.3586 315 2.1261
528 1.0697 330 1.9013
552 0.7656 345 1.7193
576 0.5927 360 1.5759
600 0.5203 375 4.4740
624 0.5067 390 4.2774
648 0.5604 405 4.1293
672 0.6357 420 4.1693
696 0.7245 435 4.0630
720 0.7881 450 4.1130
744 0.7481 465 5.1722
768 0.6318 480 3.8805
792 0.4802 495 3.7559
816 0.3621 510 3.3221
840 0.2903 525 2.9122
864 0.2413 540 3.8805
888 0.2350 555 3.7559
912 0.2552 570 3.3221
936 0.2558 585 4.1293
960 0.2213 600 3.3333
This data is an example so do not create a logic for the data. Only a generic code will be helpful. Thanks.

Best Answer

Data = [24 1.4050 15 9.4526
48 0.8348 30 7.7970
72 1.0272 45 6.8056
96 1.2513 60 6.0248
120 1.5518 75 5.3847
144 2.1398 90 5.1452
168 3.2061 105 4.7522
192 3.6026 120 4.4740
216 3.0298 135 4.2774
240 1.9868 150 4.1293
264 1.4370 165 4.1693
288 1.1396 180 4.0630
312 0.9630 195 4.1130
336 0.9592 210 4.1511
360 0.8783 225 3.8805
384 0.8384 240 3.7559
408 0.8365 255 3.3221
432 0.8786 270 2.9122
456 1.0791 285 2.5477
480 1.2648 300 2.2394
504 1.3586 315 2.1261
528 1.0697 330 1.9013
552 0.7656 345 1.7193
576 0.5927 360 1.5759
600 0.5203 375 4.4740
624 0.5067 390 4.2774
648 0.5604 405 4.1293
672 0.6357 420 4.1693
696 0.7245 435 4.0630
720 0.7881 450 4.1130
744 0.7481 465 5.1722
768 0.6318 480 3.8805
792 0.4802 495 3.7559
816 0.3621 510 3.3221
840 0.2903 525 2.9122
864 0.2413 540 3.8805
888 0.2350 555 3.7559
912 0.2552 570 3.3221
936 0.2558 585 4.1293
960 0.2213 600 3.3333];
x1 = Data(:, 1);
y1 = Data(:, 2);
x2 = Data(:, 3);
y2 = Data(:, 4);
x = linspace(240, 480, 100); % or linspace(240, 480, 400) or whatever you want
y12 = interp1(x1, y1, x) + interp1(x2, y2, x);
plot(x, y12)
hold
plot(x1,y1, 'r')
plot(x2,y2, 'g')