简体   繁体   English

根据 matlab 中另一个表中的值重新分配一个表中的值

[英]reassign values in one table, based on value in another table in matlab

I have a table in matlab ("data_table"), and I would like to reassign some values to NaN by looking up a logical "1" in another table - ("artifact_table").我在 matlab(“data_table”)中有一个表,我想通过在另一个表(“artifact_table”)中查找逻辑“1”来将一些值重新分配给 NaN。 All cells which have a 1 need to be assigned a NaN value in "data_table"所有具有 1 的单元格都需要在“data_table”中分配一个 NaN 值

在此处输入图像描述

在此处输入图像描述 so the end result is this:所以最终结果是这样的:

在此处输入图像描述

I'm unsure if it's possible to directly do this in one line of code, but you can do the following using a temporary variable (from the docs here ).我不确定是否可以在一行代码中直接执行此操作,但您可以使用临时变量(来自此处的文档)执行以下操作。 This assumes you haven't changed the name of the second dimension in the table from its default value Variables .这假设您没有更改表中第二个维度的默认值Variables的名称。

data = data_table.Variables;
data(artifact_table.Variables == 1) = NaN;
data_table.Variables = data;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM