필터 지우기
필터 지우기

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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 1일
편집: Azzi Abdelmalek 2013년 5월 1일
What do you mean by readable?
doc cellfun

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by