Assign a value to multiple cells in matlab

前端 未结 4 1155
旧时难觅i
旧时难觅i 2020-12-30 05:38

I have a 1D logical vector, a cell array, and a string value I want to assign.

I tried \"cell{logical} = string\" but I get the following error:

The         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 06:05

    As H.Muster said, deal is the way to go here. The reason for the brackets is that (following H.Muster's setup) a{b} returns a comma-separated list; the brackets need to be placed around this list to concatenate it into a vector. Running help lists in Matlab might further clarify, as might the documentation on comma-separated lists

    Edit: The answer provided by user2000747 seems much cleaner than using deal.

提交回复
热议问题