loop for a series of changing variable or tables

1 次查看(过去 30 天)
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