a simple way will be to use a for loop with ~isnan
on each row, for example:
B=NaN(size(A));
for n=1:size(A,1)
B(n,1:sum(~isnan(A(n,:))))=A(n,~isnan(A(n,:)));
end
B =
0.2500 0.3750 NaN NaN NaN
0.1100 0.4310 0.1250 NaN NaN
0.1250 0.2500 0.3750 0.4310 NaN
you can then assign A=B
if you must... and yes this can be done without a for loop, but why bother in this case?