Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

combined operations on struct arrays

2 vues (au cours des 30 derniers jours)
Archit
Archit le 1 Mai 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 ]

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 1 Mai 2013
Modifié(e) : Azzi Abdelmalek le 1 Mai 2013
S=struct('a',cellfun(@plus, {S.a},{5 6 7},'un',0))
  4 commentaires
Archit
Archit le 1 Mai 2013
Modifié(e) : Archit le 1 Mai 2013
as i said, i want something readable which should not be cryptic so ur two answers do not serve me
Azzi Abdelmalek
Azzi Abdelmalek le 1 Mai 2013
Modifié(e) : Azzi Abdelmalek le 1 Mai 2013
What do you mean by readable?
doc cellfun

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by