Making elements in an array zero

3 ビュー (過去 30 日間)
deep
deep 2019 年 1 月 30 日
コメント済み: deep 2019 年 1 月 30 日
Hello everyone,
This might be a very basic question or not im not sure.
I have an array say
[1 5 7 9 3 7 0 0 0
1 5 7 9 3 7 0 0 0
1 5 7 9 3 7 0 0 0
1 5 7 9 3 7 0 0 0
1 5 7 9 3 7 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0]
I have to empty these zeros from the table maintaing the array structure as the cell locations are assigned to some other variables.
Even though i make them blank in the input file, when it is read using uiget file this appears as nan and that i converted to zero assuming that the interp1 will work out .
But unfortunately it accounts for these zeros and throws unique grid points error.
So i plan to make these zero's blank or rather the nan elements to blank.
Can anyone help me in this?
I cannot disturb the row column used in the array.
Hope to get a solution.
Thank you
  2 件のコメント
madhan ravi
madhan ravi 2019 年 1 月 30 日
So you want to basically replace zeros with nan or remove the entire row/column filled with zeros?
deep
deep 2019 年 1 月 30 日
I have to remove the entire rows /column, so that they are not involved in carrying out the interpolation.If i keep them as zeros interpolation throws error.

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

採用された回答

madhan ravi
madhan ravi 2019 年 1 月 30 日
a(~any(a,2),:)=[]; % where a is your matrix
a(:,~any(a))=[]
  1 件のコメント
deep
deep 2019 年 1 月 30 日
This worked
Thank you

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

その他の回答 (1 件)

KSSV
KSSV 2019 年 1 月 30 日
編集済み: KSSV 2019 年 1 月 30 日
Let A be your matrix.
A(A==0) = NaN ;
  1 件のコメント
deep
deep 2019 年 1 月 30 日
My intention is to remove them, not assign nan.
Thank you

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

カテゴリ

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