フィルターのクリア

Replace values in matrix

2 ビュー (過去 30 日間)
Volkan Yangin
Volkan Yangin 2017 年 3 月 6 日
編集済み: Volkan Yangin 2017 年 3 月 6 日
Hi everybody I have a matrix, for ex: A=[2 5 7 12 9 4] and another matrix B=[1 4]
ı want to replace elements apart from 1. and 4. as "NaN". (2., 3., 5., and 6., element must be equal to NaN) I tried if command, but i took an error. Is there any pratical command for this operation? Thanks.

採用された回答

Stephen23
Stephen23 2017 年 3 月 6 日
>> A = [2,5,7,12,9,4];
>> B = [1,4];
>> A(~ismember(1:numel(A),B)) = NaN
A =
2 NaN NaN 12 NaN NaN
  1 件のコメント
Volkan Yangin
Volkan Yangin 2017 年 3 月 6 日
編集済み: Volkan Yangin 2017 年 3 月 6 日
Thank you Mr.Cobeldick.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by