How to replace values of a variable in a table (in a cell) with nan?

5 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 10 月 4 日
コメント済み: Tomaszzz 2022 年 10 月 4 日
Hi all,
I have a 10x1 cell containg 100x32 tables.
I want to:
mycell{5, 1}.myvariable = nan;
which results in:
Error using .
To assign to or create a variable in a table, the number of rows must match the height of the table.
How can I write the code to replace the values of a specified variable with nan?
Can you help please?
  2 件のコメント
Rik
Rik 2022 年 10 月 4 日
I'm on mobile so I can't test it, but perhaps this works:
[mycell{5, 1}.myvariable] = deal(NaN);
Tomaszzz
Tomaszzz 2022 年 10 月 4 日
Thanks@Rik. Unfortunately the same error.

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

採用された回答

VBBV
VBBV 2022 年 10 月 4 日
mycell{5, 1}(1,1).myvariable = nan;
  2 件のコメント
Tomaszzz
Tomaszzz 2022 年 10 月 4 日
Thanks@VBBV. It results:
Error using ()
Adding rows or variables to a table by an assignment where () or {} subscripting is followed by additional
levels of subscripting is not supported.
The below replace the first row with nan; not sure how to apply it to all rows?
mycell{5, 1}(1,:).myvariable = nan;
Tomaszzz
Tomaszzz 2022 年 10 月 4 日
ok now it works;
mycell{5, 1}.myvariable(:,1) = nan;

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by