Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Firas Al-Kharabsheh
Firas Al-Kharabsheh am 15 Apr. 2016
i'am new in matlab and not good in code .. can you help me to write it ??
Stephen23
Stephen23 am 15 Apr. 2016
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.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by