From: Aaron Anstey on
I have a matrix of two columns, the first column contains a range of numbers and so does the second column. When the value in the first column is "50", I want Matlab to output the corresponding value for that row in the second column.
Can anyone please tell me the command I can use for this?
Many thanks.
From: dpb on
Aaron Anstey wrote:
> I have a matrix of two columns, the first column contains a range of
> numbers and so does the second column. When the value in the first
> column is "50", I want Matlab to output the corresponding value for that
> row in the second column. Can anyone please tell me the command I can
> use for this? Many thanks.

doc find

--
From: Andy on
"Aaron Anstey" <elaja2(a)lboro.ac.uk> wrote in message <i3sa4a$c7m$1(a)fred.mathworks.com>...
> I have a matrix of two columns, the first column contains a range of numbers and so does the second column. When the value in the first column is "50", I want Matlab to output the corresponding value for that row in the second column.
> Can anyone please tell me the command I can use for this?
> Many thanks.

Does "output" mean at the command line?

>> a=[(1:100)' rand(100,1)]; % sample data
>> a(a(:,1)==50,2) % outputs the second column where the first column is 50
From: machatsk on
"Aaron Anstey" <elaja2(a)lboro.ac.uk> wrote in message <i3sa4a$c7m$1(a)fred.mathworks.com>...
> I have a matrix of two columns, the first column contains a range of numbers and so does the second column. When the value in the first column is "50", I want Matlab to output the corresponding value for that row in the second column.
> Can anyone please tell me the command I can use for this?
> Many thanks.

matrix(50,2) %gets value of 50th row, 2nd column
Maxx
From: Aaron Anstey on
"Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i3saj9$cpq$1(a)fred.mathworks.com>...
> "Aaron Anstey" <elaja2(a)lboro.ac.uk> wrote in message <i3sa4a$c7m$1(a)fred.mathworks.com>...
> > I have a matrix of two columns, the first column contains a range of numbers and so does the second column. When the value in the first column is "50", I want Matlab to output the corresponding value for that row in the second column.
> > Can anyone please tell me the command I can use for this?
> > Many thanks.
>
> Does "output" mean at the command line?
>
> >> a=[(1:100)' rand(100,1)]; % sample data
> >> a(a(:,1)==50,2) % outputs the second column where the first column is 50

Many thanks, this works.