if at least one number > in cell

1 vue (au cours des 30 derniers jours)
Tomas
Tomas le 30 Nov 2013
Commenté : Tomas le 30 Nov 2013
I have cell {1x7}
C{1}{1}=[ 5.4000 8.3000 15.8000]
C{1}{2}=[ 9.9000 10.7000 13.600]
C{1}{3}=[ 5.5000 8.9000 15.5000]
C{1}{4}=[ 9.7000 11.0000 13.9000]
C{1}{5}=[5.7000 8.1000 15.1000]
C{1}{6}=[9.4000 10.5000 13.0000]
C{1}{7}=[9.9000 13.2000 13.7000]
number=6.6;
if C{1}{1}> as number stored to W{1}, if no stored do W{2}
Thanks.
  3 commentaires
Tomas
Tomas le 30 Nov 2013
if C{1}{1}>number
5.4>number 8.3>number 15.8> number
W{1}{1}=C{1}{1} if no
W{2}{1}=C{1}{1}
Tomas
Tomas le 30 Nov 2013
C{1x7} C{1}{1}=[ 5.4000 8.3000 15.8000] C{1}{2}=[ 9.9000 10.7000 13.600] C{1}{3}=[ 5.5000 8.9000 15.5000] C{1}{4}=[ 9.7000 11.0000 13.9000] C{1}{5}=[5.7000 8.1000 15.1000] C{1}{6}=[9.4000 10.5000 13.0000] C{1}{7}=[9.9000 13.2000 13.7000] number=6.6; for i=1:size(C,2) for j=length(C{1})
if any(C{i}{j}>number) W{i}{j}=C{i}{j} else W{i+1}{j}=C{i}{j}
it does not work,everything stored in one

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 30 Nov 2013
number=6.6;
if all(C{1}{1}>number)
W{1}{1}=C{1}{1}
else
W{2}{1}=C{1}{1}
end
  2 commentaires
Tomas
Tomas le 30 Nov 2013
Thanks
Tomas
Tomas le 30 Nov 2013
I have one more problem I do not know in the cell to save if I have more cell
for example if have cell Z{1}={1x7} Z{2}={1x4}
I need to split Z{1} and Z{2}
need it to write in one loop, I do not know how to index the

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