I have a matrix:
A= [0 80 -100 0 1 0 1 0 1 0 1 ;...
0 0 0 0 1 0 1 1 0 1 0 ;...
-100 0 0 0 1 1 0 0 1 0 1 ;...
-100 100 0 0 1 1 0 1 0 1 0 ;...
100 0 -100 1 0 0 1 0 1 0 1 ;...
100 0 0 1 0 0 1 1 0 1 0 ;...
0 0 0 1 0 1 0 0 1 0 1 ;...
0 100 0 1 0 1 0 1 0 1 0 ]
Now i need to make a function if i type:
0 1 0 1 0 1 0 1
then it will show the corresponding total row. so, it'll show:
0 80 -100 0 1 0 1 0 1 0 1
But i don't know how to do. Can anyone please help me?

4 个评论

madhan ravi
madhan ravi 2019-1-24
编辑:madhan ravi 2019-1-24
Which row corresponds and why???
Sky Scrapper
Sky Scrapper 2019-1-24
编辑:Sky Scrapper 2019-1-24
Look, I have searched the 1st row from column 4 to 11 and it's showing the total 1st row. I will have to search randomly from any rows within column 4 to 11, Say, if i search for the 3rd row:
0 1 1 0 0 1 0 1
then it will show:
-100 0 0 0 1 1 0 0 1 0 1
The result you want is simply the first row of ‘A’.
Is the argument vector you want to enter in your function some sort of code that the function has to interpret?
Sky Scrapper
Sky Scrapper 2019-1-24
编辑:Sky Scrapper 2019-1-24
I will enter the value (of column 4 to 11), it will search the whole matrix and find out in which row that given data is found and will show.

请先登录,再进行评论。

 采纳的回答

tofind = [0, 1, 1, 0, 0, 1, 0, 1];
found = A(ismember(A(:, 4:11), tofind, 'rows'), :)
will return all the rows of A whose columns 4 to 11 match tofind.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by