Using command fill with functions created by csv file

Hi, I have two curves created by two differents files CSV, and i’m trying to use the command “fill” to paint the difference between the curves.

But using the following script, occurs the total painting.:

clear all
close all
clc

M1 = dlmread(“Test2.csv”,";",49,0);
time1 = M1(:,1)*(1e-6)-(1.92e-6);
Data1 = M1(:,2);

M3 = dlmread(“Test1.csv”,";",49,0);
time3 = M3(:,1)*(1e-6)-(1.92e-6);
Data3 = M3(:,2);

figure
hold on;
grid on;

plot(time1,Data1, ‘LineWidth’, [2], ‘b’)
plot(time3,Data3,‘LineWidth’, [2],‘k’)

fill ([time3,time1],[Data3,Data1], “y”);

Could you please indicate where I am going wrong? Thx.

fill draws a filled polygon with the given vertices. In your command, one of the edges of that polygon is the connecting line from the [time3(end), Data3(end)] to [time1(1), Data1(1)].
Maybe, try reverting one of those lines because it looks like their respective start and end points are pretty close to each other.
I’m not sure if this will result in the exact result you’d like…

try this:

x=0 : 0.1 : 3 ; 
y=sin(x);
y1=sin(x.*0.9);
plot(x,y,x,y1);
x2=[ x, flip(x)]; 
y2=[y, flip(y1)];
fill(x2, y2, 'y');

I must say, in your particular case, as there is no math involved, and you seem to have data already in csv format, you are far better off representing data by using excel. Look, a few minutes and we have beautiful chart like this

I am talking about choosing the right tool for the job. Hope this helps, I am very beginner Octave user, very-very new to all this.