Info

此问题已关闭。 请重新打开它进行编辑或回答。

combined operations on struct arrays

2 次查看(过去 30 天)
Archit
Archit 2013-5-1
关闭: MATLAB Answer Bot 2021-8-20
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 ]

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-5-1
编辑:Azzi Abdelmalek 2013-5-1
S=struct('a',cellfun(@plus, {S.a},{5 6 7},'un',0))
  4 个评论
Archit
Archit 2013-5-1
编辑:Archit 2013-5-1
as i said, i want something readable which should not be cryptic so ur two answers do not serve me

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by