loop for a series of changing variable or tables

조회 수: 1 (최근 30일)
mirewuti muhetaer
mirewuti muhetaer 2020년 3월 25일
댓글: darova 2020년 3월 26일
Hi,
If i have a series of tables such as AX1, AX2,,,,,AX10.
And i want to extract element B from each AX sereis and save it in a new table.
I tried the following idea, but failed:
new_var=zeros(10,1);
for i=1:10;
new_var(i,1)=AZ'i'(5,1);
end;
But it did not work.
can someone help.
Thanks.

채택된 답변

darova
darova 2020년 3월 25일
My solution
A1 = table(1,2);
A2 = table(1,2);
A = {A1 A2};
for i = 1:2
AA = A{i};
new_var(i,1) = AA(5,1);
end
  댓글 수: 2
mirewuti muhetaer
mirewuti muhetaer 2020년 3월 25일
Hi, can you help me check this code:
Tjp={T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14 T15};
n4=200;
for i=1:n2
for j=1:n4
TT1=Tjp{i};
if TT1(j,1) == "David"
jpmorgan(1,Q22016)=str2double(TT1(j,3));
end
end
end
But i always gives me this warning: Undefined operator '==' for input arguments of type 'table'.
Thanks.
darova
darova 2020년 3월 26일
You can compare number using == operator
Use strcmp for string
if strcmp(TT1(j,1), "David")

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by