I am trying to mask values in a matrix that are out of a specified range and trying to make a new matrix from the values after the values out of the range have been masked.
59 ビュー (過去 30 日間)
古いコメントを表示
I am trying to mask values in a matrix that were calculated using values of theta. I am trying to mask values that are less that 20 deg. From the values that have not been masked I am trying to make a new matrix
i.e.
Gamma - matrix before mask values
gamma - new matrix after values have been masked
gamma = (somefunction to mask Gamma)
0 件のコメント
採用された回答
Voss
2022 年 2 月 18 日
編集済み: Voss
2022 年 2 月 18 日
It's not entirely clear exactly what you have in mind, but one or more of these options should cover it. If not, please explain further.
% some theta values:
theta = [0:4 5:5:30]
% calculate Gamma using some function of theta:
Gamma = theta.^2
% take the values of Gamma greater than or equal to 20:
gamma = Gamma(Gamma >= 20)
% or take the values of Gamma where theta was greater than or equal to 20:
gamma = Gamma(theta >= 20)
% or set the values of Gamma less than 20 to NaN
gamma = Gamma;
gamma(Gamma < 20) = NaN
% or set the values of Gamma less than 20 to 0
gamma = Gamma;
gamma(Gamma < 20) = 0
% or set the values of Gamma where theta was less than 20 to NaN
gamma = Gamma;
gamma(theta < 20) = NaN
% or set the values of Gamma where theta was less than 20 to 0
gamma = Gamma;
gamma(theta < 20) = 0
0 件のコメント
その他の回答 (1 件)
DGM
2022 年 2 月 18 日
編集済み: DGM
2022 年 2 月 18 日
This is all still terribly nonspecific. "Masking" may be generally read as "selecting". What is to happen to the undesired elements? Are they set to zero? To NaN? ... or do the workflow allow the extraction of the desired elements alone, perhaps as a vector?
Consider the array of angles:
A = reshape(round(linspace(0,40,25)),5,5)
mask = A<20
% set masked values to 0
B = A;
B(mask) = 0
% set masked values to NaN
C = A;
C(mask) = NaN
% extract vector of unmasked values
D = A(~mask)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Gamma Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!