Using the void elements in matlab

1 回表示 (過去 30 日間)
rahul sharma
rahul sharma 2017 年 1 月 5 日
回答済み: Sean de Wolski 2017 年 1 月 5 日
I am multiplying an array, say A= [1 0 1 0 0] with another array B=[1 _ _ 0 _]. Now I want to compare only certain bits of B with A not all the values. So, I was thinking of taking 'void values' at 2nd, 3rd and 5th places of B which will have no role to play at all. Is there any type of data type that can be used for such purposes. (Note: I have taken A and B to be quite small so that I can explain my problem. I have both the array of size in 4000's and I have to perform convolution so I have to shift one array all the time. So, I don't think it's good idea to compare the two array only for the places that I want. The better way I thought is to insert these 'null' values which plays no role in computation at all.)
  2 件のコメント
Jos (10584)
Jos (10584) 2017 年 1 月 5 日
What should be the result of the computation in your example?
rahul sharma
rahul sharma 2017 年 1 月 5 日
It should be 2. Just compare the number of bits which are matching.

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

回答 (1 件)

Sean de Wolski
Sean de Wolski 2017 年 1 月 5 日
Use a NaN.
x = [1 nan nan 3];
sum(~isnan(x))

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by