フィルターのクリア

Change value of corresponding column depending on conditions

7 ビュー (過去 30 日間)
Claire Hollow
Claire Hollow 2020 年 6 月 1 日
コメント済み: Claire Hollow 2020 年 6 月 1 日
Helllo! I have a 23000x14 table of data. Im trying to do something where I go through all of the values in column 10 and if it column 10 gives the value of 15 then the same row that has that values of 15 but in column 9 gets changed to 'NA'. So for exmaple:
Original
5 4
45 15
32 6
After
5 4
NA 15
32 6
I've tried a few things but nothing has worked for me so far. Any help is greatly appreciated, thank you!

採用された回答

KSSV
KSSV 2020 年 6 月 1 日
You cannot put NA, but you can replace that with NaN. Try this.
A = [5 4
45 15
32 6] ;
idx = A(:,2)==15 ; % get logical indices of second column which has 15
A(idx,1) = NaN ; % replace the first column with NaN which has 15 in the second column
  3 件のコメント
KSSV
KSSV 2020 年 6 月 1 日
If it is table, you should be able to add NA....make it a string and try to add..
station001_eus{idx,9}= 'NA';
Claire Hollow
Claire Hollow 2020 年 6 月 1 日
Ok so now I did try that
idx=station001_eus{:,10}==(',,7');
station001_eus{idx,9}='NA';
and im getting the error
The value on the right-hand side of the assignment
has the wrong width. The assignment requires a
value whose width is 1.
for the second line again. Im not sure how to work past this.
Sorry for the all the questions, you've been super helpful!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by