Hello all,
I am having significant problems with the floating point numbers while scripting in MATLAB.
I have a data sheet having more than 230000 rows and 33 columns. What I need to do is that if a particular condition satisfy in one column ( column 17) I have to find that particular row index where this condition satisfy and I have to extract the correspoding value in the same row of a diferent column ( column 19) and return it into a vector.
I am able to extract everything in to a new vector (it is a 139×1 matrix). However, all values which are below 1, naturally decimal numbers, return as 0 in my new matrix. Everything above one is returned properly. I've read many troubleshoot questions in this forum by using tolerance (I have successfully used tolerance method for comparing floating point decimals in other parts of the script) but nothing seem to work for this particular issue. Can anyone help me in this ? . I will grab a screenshot of a small part of the data as well as the code and put it here for your reference.
Any help is appreciated
As you can see in the below screenshot, I need to get the first instant of a negative number in column 17 (here -6.5021e+03) and the return the corresponding value from column 19 (here 0.0060). It repeats many times (139) over the 230000 rows. The below is the code I have used. I have extracted that particular column 19 and saved it as a 230000×1 variable vector called DisCap. s_dis is the new matrix where the data needs to be saved and indices_res is the row indices inside a for loop.
S_dis(j-1,:)=DisCap(indices_res(j-1));
This code should save all the values from the indices_res rows of DisCap.
Best Answer