loop for a series of changing variable or tables

1 view (last 30 days)
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.

Accepted Answer

darova
darova on 25 Mar 2020
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 Comments
mirewuti muhetaer
mirewuti muhetaer on 25 Mar 2020
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 on 26 Mar 2020
You can compare number using == operator
Use strcmp for string
if strcmp(TT1(j,1), "David")

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!