フィルターのクリア

Acces to element of matirx

2 ビュー (過去 30 日間)
Dani D
Dani D 2016 年 2 月 27 日
回答済み: Star Strider 2016 年 2 月 27 日
Hello, I want check element of matrix no value element of matrix. but i have an error,
for i=1:row
for j=1:co
if ((i,j) >=A && (i,j) <B)
  2 件のコメント
per isakson
per isakson 2016 年 2 月 27 日
編集済み: per isakson 2016 年 2 月 27 日
  • "element of matrix no[t] value element of matrix" &nbsp What do you mean?
  • What error do you have?
  • A and B what class are they?
dpb
dpb 2016 年 2 月 27 日
Don't understand what no "value element of matrix" means, precisely, but your expression in the if is missing a reference to an array by the subscripting expression. Something like
if (x(i,j) >=A && x(i,j) <B)
would serve to compare the elements of the array x to A and B presuming the latter are constants. Of course, w/ Matlab, you don't need the loop at all, simply
ix=(x>=A & x<B);
will return a logical array of True|False (1|0 numerically).

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2016 年 2 月 27 日
I believe something like this is what you want:
Matrix = randi(9, 5) % Create Data
A = 4;
B = 6;
Result = (Matrix >= A) & (Matrix <= B) % Logical Matrix
Matrix =
9 7 6 3 9
4 5 8 8 7
7 5 8 1 5
2 9 6 5 5
1 6 2 2 1
Result =
0 0 1 0 0
1 1 0 0 0
0 1 0 0 1
0 0 1 1 1
0 1 0 0 0

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by