【问题标题】:How to set a number in a couple of cells within a cell array [duplicate]如何在单元格数组中的几个单元格中设置一个数字[重复]
【发布时间】:2012-10-15 22:56:49
【问题描述】:

可能重复:
Assign a value to multiple cells in matlab

我正在尝试在第 2 列中的所有空单元格中输入一个数字,比如说 3。

像这样:

emptyList = cellfun(@isempty,anscell)
anscell{emptyList(:,2),2}=3

但我收到这条消息

The right hand side of this assignment has too few values to satisfy the left hand side.

我可以在没有循环和创建 sum 和 one 函数的情况下克服它吗?

【问题讨论】:

    标签: matlab cell cells


    【解决方案1】:

    这是你需要的吗?

    anscell = cell(3,2)
    emptyList = cellfun(@isempty,anscell)
    anscell(emptyList(:,2),2)={3}
    

    【讨论】:

      【解决方案2】:

      这是你想做的吗?

      [anscell{emptyList(:,2),2}] = deal(3)
      

      【讨论】:

      • 嗯,它可能是它,但它仍然不起作用。我认为是因为我访问我的单元格的方式不好,可能是?
      猜你喜欢
      • 2021-11-29
      • 2013-02-17
      • 1970-01-01
      • 2016-08-22
      • 2013-01-29
      • 2019-01-13
      • 2021-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多