Effacer les filtres
Effacer les filtres

loop for a series of changing variable or tables

2 vues (au cours des 30 derniers jours)
mirewuti muhetaer
mirewuti muhetaer le 25 Mar 2020
Commenté : darova le 26 Mar 2020
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.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by