Two things:
1) Using a loop for what you want is inefficient and probably will lead to bugs if you're not careful. What you want can be achieved much more easily without a loop. I'm not exactly sure what you mean by the the first instant of a negative number. If you mean _get all values in column 19 for which column 17 are negative, it's simply:
s_dis = yourmatrix(yourmatrix(:, 17) < 0, 19);
If you mean the first negative value of a continuous run of negative values, it's a bit more complicated
isstartofarun = diff([false; yourmatrix(:, 17) < 0]) == 1;
s_dis = yourmatrix(isstartofarun, 19);
If you mean something else, you'll have to be clearer.
2) The way matlab displays number has no bearing on what is truly stored in the matrix. Whatever is stored in the matrix will be unchanged after the above (or your for loop). However, depending on the magnitude of the numbers and the display format that you're using some numbers may display as 0. Their actual value will still be used for all calculation You can change the display format of the command with the format command, personally I use format longg, and the display format of the variable browser in the view tab of matlab toolbar.
Best Answer