Assign multiple fields to a Struct-Array
조회 수: 8 (최근 30일)
이전 댓글 표시
hi, I'm new to struct Arrays and I've got the following problem:
filelist(:).names = upper(filelist(:).names);
somehow I cannot figure out how to tell matlab to assign each result of the upper function to one entry in the filelist. I'm sure that there's a simple solution but I understand how until now
Thanks!
댓글 수: 0
답변 (3개)
Fangjun Jiang
2011년 9월 9일
filelist(1).names='a';
filelist(2).names='b';
a=upper({filelist.names});
[filelist.names]=deal(a{:})
댓글 수: 2
Andrei Bobrov
2011년 9월 9일
for j1 = numel(filelist):-1:1
filelist(j1).names=upper(filelist(j1).names);
end
variant with arrayfun and others
filelist = ...
cell2struct(arrayfun(@(x)upper(x.names),filelist,'un',0),fieldnames(filelist));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!