Info

此问题已关闭。 请重新打开它进行编辑或回答。

if i have a matrix i want to find some thing in this matrix and put it in a new matrix ?

1 次查看(过去 30 天)
if i have an (n,m) matrix A then i want to find some row or column in this matrix and put it in a new matrix like that
A = [ 0 0 1 0 1 1
1 0 1 0 1 1
1 1 0 0 1 0
0 1 0 1 0 1
1 0 1 1 0 1 ]
* if the row or the column have a group of one with one zero between them
* if the number of zero in this row or column < number of ones in this row
then put these rows or these column in a new (n,m) Zeros matrix like that
S_zeros = [ 0 0 0 0 0 1
1 0 1 0 1 1
0 0 0 0 0 0
0 0 0 0 0 1
1 0 1 1 0 1 ]
in S_zeros matrix the Second row in Matrix A apply the condition where
[ 1 0 1 0 1 1 ] >>>> first condition true ( one zeros between the ones )
>>>> second condition true ( number of zeros = 2 , and number of ones = (4)
then ( 2 < 4 )
but in the fourth row
[0 1 0 1 0 1 ] >>>> first condition true ( one zeros between the ones )
>>>> second condition false ( number of zeros = 3 , and number of ones = (3)
then ( 3 < 3 ) wrong
apply this conditions on the rows and columns of Matrix A
  3 个评论
Stephen23
Stephen23 2016-4-15
Here are some tips to get started:
  • Break the problem into parts, and don't try to solve it all at once.
  • find out how to loop over rows and columns, test it, check that that works.
  • then move on to the next part...
  • test and check every part as you write it.
  • understand what the code is doing.
  • read the documentation (this is a very important step!)
Read this, it has lots of useful advice to learn how to use MATLAB:
and these are some very good tutorials to get you started:
Of course you could ask people to write code for you... but you will not learn as much doing that.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by