Effacer les filtres
Effacer les filtres

for loop

7 vues (au cours des 30 derniers jours)
Kugen Raj
Kugen Raj le 22 Mar 2012
if size(qq)==[1,8]
ff=[(hh(1,1)+qq(1,2))];
ff1=[(hh(1,1)+qq(1,4))];
ff2=[(hh(1,1)+qq(1,6))];
ff3=[(hh(1,1)+qq(1,8))];
aa=kk(ff);
aa1=kk(ff1);
aa2=kk(ff2);
aa3=kk(ff3);
elseif size(qq)==[1,6] / size(qq)==[1,7]
ff=[(hh(1,1)+qq(1,2))];
ff1=[(hh(1,1)+qq(1,4))];
ff2=[(hh(1,1)+qq(1,6))];
aa=kk(ff);
aa1=kk(ff1);
aa2=kk(ff2);
elseif size(qq)==[1,4] / size(qq)==[1,5]
ff=[(hh(1,1)+qq(1,2))];
ff1=[(hh(1,1)+qq(1,4))];
aa=kk(ff);
aa1=kk(ff1);
elseif size(qq)==[1,2] / size(qq)==[1,3]
ff=[(hh(1,1)+qq(1,2))];
aa=kk(ff);
end
based on my coding, i want to calculate (aa-aa3) if the size(qq)=[1,8], (aa-aa2) if size(qq)=[1,6], (aa-aa1) of size(qq)=[1,4] and (aa only) if the size(qq)=[1,2]. Is this code correct because im not sure if it works properly.

Réponses (1)

Nathan Greco
Nathan Greco le 22 Mar 2012
The only thing that doesn't look right to me is where you have
elseif size(qq)==[1,#] / size(qq)==[1,#+1]
Where # is 6,4,2 Why do you have the second half there? I would get rid of that and just put
elseif size(qq)==[1,#]
And so on. Note: If you wanted to say if size(qq) is less than or equal to [1,3], you would need an | as such:
elseif size(qq)==[1,#] | size(qq)==[1,#+1]
-Nathan
  2 commentaires
Kugen Raj
Kugen Raj le 22 Mar 2012
how do I put it, if i want to calculate (aa-aa2) in the condition where size(qq)=[1,8] or size(qq)=[1,7]. i will have to put like size(qq)=[1,8] | size(qq)=[1,7] ?
Nathan Greco
Nathan Greco le 22 Mar 2012
Yes, just replace your /'s with |'s.

Connectez-vous pour commenter.

Catégories

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

Tags

Aucun tag saisi pour le moment.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by