Hi all,
How can I vectorize the following code?
a=struct('cycles',[])
a(1).cycles=[rand(15,20];
a(2).cycles=[rand(15,20];
a(3).cycles=[rand(15,20];
for i=1:length(a)
totalnum(i)=sum(a(i).cycles)
end
Where totalnum should be a [3,20] array.
Thanks
cheers

댓글 수: 2

Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 1일
What is a?
pietro
pietro 2014년 6월 1일
You're on right, I have just edited the question. thanks

댓글을 달려면 로그인하십시오.

 채택된 답변

dpb
dpb 2014년 6월 1일

0 개 추천

reshape(sum([a.cycles]),length(a),[]).'

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

태그

질문:

2014년 6월 1일

답변:

dpb
2014년 6월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by