combined operations on struct arrays
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
I have a struct S
S=struct()
It has 2 fields a,b
S(1).a=2;
S(2).a=3;
S(3).a=4;
now how do i do something like
S(:).a=S(:).a+[ 5 6 7 ]
Risposte (1)
Azzi Abdelmalek
il 1 Mag 2013
Modificato: Azzi Abdelmalek
il 1 Mag 2013
S=struct('a',cellfun(@plus, {S.a},{5 6 7},'un',0))
4 Commenti
Azzi Abdelmalek
il 1 Mag 2013
Modificato: Azzi Abdelmalek
il 1 Mag 2013
S=struct('field1',cellfun(@(x,y) x^2+cos(x)+const1*x*y, {S.field1},{S.field2},'un',0))
Azzi Abdelmalek
il 1 Mag 2013
Modificato: Azzi Abdelmalek
il 1 Mag 2013
What do you mean by readable?
doc cellfun
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!