How to check the number of ones from certain row to the 1st row?

1 vue (au cours des 30 derniers jours)
fyza affandi
fyza affandi le 27 Nov 2018
Commenté : Image Analyst le 27 Nov 2018
t(:,:,1) =
1 10 19 28 37 46 55 64 73 82
2 11 20 1 38 47 56 65 74 83
3 12 21 30 39 48 57 66 75 84
4 13 22 31 40 49 58 67 76 85
5 14 1 32 41 50 59 68 77 86
6 15 24 33 42 51 60 69 78 87
7 16 25 34 43 1 61 70 79 88
8 17 26 35 44 53 62 71 80 89
9 18 27 36 45 54 63 72 81 90
t(:,:,2) =
91 100 109 118 127 136 145 154 163 172
92 101 110 119 128 137 146 155 164 173
93 102 111 120 129 138 147 156 165 174
94 103 112 121 1 139 148 157 166 175
95 104 1 122 131 140 149 158 167 176
96 105 114 123 132 141 150 159 168 177
1 106 115 124 133 142 151 160 169 178
98 107 116 125 134 143 152 161 170 179
99 108 117 126 1 144 153 162 171 180
How to check the number of ones but starting from row 7 till the 1st row for both matrices?
Is it using for loop ?

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Nov 2018
squeeze( sum( t(1:7, :, :) == 1, 1 ) )
the result would be 10 x 2 -- the 10 columns of t and the 2 panes.
  3 commentaires
fyza affandi
fyza affandi le 27 Nov 2018
Modifié(e) : fyza affandi le 27 Nov 2018
What if I want it by row instead of counting ones by column?
9 rows of t and the 2 panes
Image Analyst
Image Analyst le 27 Nov 2018
Gvie numerical example, including both inputs and the desired output.
I don't even know what "row 7 till the 1st row" means. Doesn't really make sense in English. "till" usually means "until". So "row 7 until..." would mean from row 7 (inclusive) until some row larger than 7, like 8, 9, 100, etc. NOT row 1, which is in the backward/smaller direction.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by