Assign multiple fields to a Struct-Array
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
Fangjun Jiang
el 9 de Sept. de 2011
filelist(1).names='a';
filelist(2).names='b';
a=upper({filelist.names});
[filelist.names]=deal(a{:})
2 comentarios
Andrei Bobrov
el 9 de Sept. de 2011
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 comentarios
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!