Matrix "User Define"

1 回表示 (過去 30 日間)
ANAND ASP
ANAND ASP 2020 年 11 月 26 日
コメント済み: KSSV 2020 年 11 月 26 日
i wanna make matrix like user define matrix
take input from user but in case user dont know the value, they can put "NO"
user (2,2) dont know the value,
Matrix= 12 45 5
50 NO 63
45 56 66
that value i can read and modified also...

回答 (1 件)

KSSV
KSSV 2020 年 11 月 26 日
What you gave is a combination of numbers and strings.....this cannot be acieved by a matrix. But you can use cell arrays for this.
A = [{1} {2} ; {'NO'} {3}] ;
If you want matrix, you can consider repalcing with NaN instead of NO
A = [1 2 ; NaN 3] ;
  1 件のコメント
KSSV
KSSV 2020 年 11 月 26 日
Yes easily can be changed...you can get the indices of NaN using isnan.
idx = isnan(A) ; % get logical indices of NaN
A(idx) = 3 ;

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by