I have solved the problem. I'm going to leave my example if anyone needs it:D
read Excel sheet
[num,txt,raw]=xlsread('X.xls','X1');
copy data
rowData={Z, X1, Y1, X2, X3, Y0, UP}; (the data i want to write)
make it go to next row
row =(size(raw,1))+1;
search for empty row between data in and if it exists write in it then stop
[nm, nn] = size(raw);
for im=1:nm
NaNIndex = find(isnan(raw{im}));
if NaNIndex==1
xlswrite(...);
break
end
end
if there isn't an empty row write after the last row
if isempty(NaNIndex)
xlswrite(...);
end