For loop with multiple variables

Why does this not success??
values_1=[1 2]
values_2=[2 3]
values_3=[3 4]
values_4=[4 5]
values_5=[5 6]
for i=1:5
X = num2str(i)
values_'X'a(i,:)=sum(values_'X'(i,:),2);
end
I'd like to do this using by for loop:
values_1a(i,:)=sum(values_1(i,:),2);
values_2a(i,:)=sum(values_2(i,:),2);
values_3a(i,:)=sum(values_3(i,:),2);
values_4a(i,:)=sum(values_4(i,:),2);
values_5a(i,:)=sum(values_5(i,:),2);

댓글 수: 4

KSSV
KSSV 2020년 4월 12일
You cannot use like that.......what data you have? what are these values_1, values_2......?
Ryosuke Saito
Ryosuke Saito 2020년 4월 12일
편집: Ryosuke Saito 2020년 4월 12일
values_1, values_2... are tables. I added the information.
Ryosuke Saito
Ryosuke Saito 2020년 4월 12일
Oh thanks. I understood.

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

답변 (1개)

Mehmed Saad
Mehmed Saad 2020년 4월 12일

0 개 추천

eval Function (Not Recommended) but it will do what you are trying here

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 4월 12일

댓글:

2020년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by