I'm sorry but I can't give you the answer - because I don't understand it.
This is like you said. x is a vector, D is the significant decimals and y is also a vector.
ex = D - ceil(log10(abs(x)));
ex is a vector, too. D is an integer like 10. And x is a vector [5,3,-1]
abs(x) leads to the vector [|5|,|3|,|-1| ] = [5,3,1]
log10(x) -> you get the vector [log(5),log(3),log(1)]
So what does ceil do? For this syntax you should use google or go to the official website of matlab, because there is a good documentation.
You find this:
In my opinion it explains it very good what ceil does, because there is a nice example.
It is D = 10 for example and you solve ceil(...).
For example you have 10 - [3,5,7] then matlab returns the vector [10-3, 10-5, 10-7]
I don't know what happens in the next line if the vector has a negative number in it.
y = round(x.*(10.^ex)).*(10.^(-ex));
Use the Matlab documentation I showed you to find out how round() works.
The critical thing here is the point ' . ' You need it if you calculate * or / or ^ or... then you get this: You have two vectors [x_1,...,x_n] and ex_1,...ex_n
= round([x_1*10^ex_1)*10^(-ex_1),...,[x_n*10^ex_n)*10^(-ex_n) ])
But this could be wrong. I don't have matlab either. I just think this is what Matlab does. If not, I'm sorry, but no one hasn't responded yet, so I thought it might help.