필터 지우기
필터 지우기

Remove field from structure nested in a cell array

조회 수: 6 (최근 30일)
Laila Rezai
Laila Rezai 2019년 9월 7일
댓글: Laila Rezai 2019년 9월 7일
Hi,
I have a cell array (y_fast) of 16x1. Inside of each cell, there is a structure with two fields: Outdata and Outlist. I want to remove field called Outdata from each cell array. The complete name of field I want to remove is in my code y_fast{1,1}.Outdata. I wirte this easy command as example for the first cell array:
y_fast{1,1}=rmfield(y_fast{1,1},Outdata);
but comes the following error:
Undefined function or variable 'Outdata'.
although Outdata is already defined.
Could someone wirte me why??

채택된 답변

madhan ravi
madhan ravi 2019년 9월 7일
편집: madhan ravi 2019년 9월 7일
cellfun(@(x)rmfield(x,'Outdata'),y_fast,'un',0) % see the quotes around Outdata
doc rmfield
help rmfield
  댓글 수: 4
Bruno Luong
Bruno Luong 2019년 9월 7일
Assign the result to the variable
y_fast = cellfun(@(x)rmfield(x,'Outdata'),y_fast,'un',0)
Laila Rezai
Laila Rezai 2019년 9월 7일
Thank you very much:). It works now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by