0
votes

I have a matrix A where i found the row index with min value:

  [val, ind] = min (S)

how to get the value of this row at column 1?

The data I use in text file A:

dat    Y         S
100    0.86     105
 ...
20     0.4     145

I Find the min of S column. index the row 'ind' and need to return 'dat' column value of the correpsong row.

So e.g. S(min) = 105, [ind]=1, i need to return dat = 100.

Sorry for basic question.

Thanks

1
Use out = dat(ind)?Divakar
Superb! That worked. Thanks a lot!mil
@Divakar. I read help on indices but still not clear. How do i get all columns of the row at 'rowindex==ind'? in case i need to work with column values: e.g. subtract and divide by certain number? Many thanks! i need something like 'out = dat/3, Y/3, S/3' so that I could work with column values (here divide by 3).mil
Maybe you can post that as a separate question, as it sounds entirely different?Divakar

1 Answers

1
votes

I assume that you have read your textfile into the variable A

[val, ind] = min(A(:,3))

ind is now your row number.

Then you just do

A(ind,1)