フィルターのクリア

How do I make an entire row in a table NaN?

32 ビュー (過去 30 日間)
FsC
FsC 2022 年 10 月 27 日
コメント済み: FsC 2022 年 10 月 27 日
I am trying to make all values in specific rows of a table NaN.
My table (T) contains 4 columns (time, x position, y position, pressure). I use the value of the pressure to determine when X and Y are 'on' or 'off'. I then want to set all values in rows where it is 'off' to NaN
% get on and off T data
isOn = find(T.Pressure >0);
isOff = find(T.Pressure==0);
I have tried the following:
T(isOff,:) = NaN;
as well as:
for i = 1:length(isOff)
T(i,:) = NaN
end
But both give the error: Right hand side of an assignment into a table must be another table or a cell array.
What is the issue? Is there a way to do this using vectorization without having an extensive loop?
Thank you for your help!

採用された回答

David Hill
David Hill 2022 年 10 月 27 日
T(isOff,:) = {NaN};%does this work?
  1 件のコメント
FsC
FsC 2022 年 10 月 27 日
Yes! Thank you!

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

その他の回答 (1 件)

Voss
Voss 2022 年 10 月 27 日
T{isOff,:} = NaN; % use curly braces {}

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by