Incrementer une valeur dans un tableau matlab
Fermé
kanwulf62
Messages postés
2
Date d'inscription
mercredi 29 mai 2013
Statut
Membre
Dernière intervention
1 juin 2013
-
29 mai 2013 à 14:27
Char Snipeur Messages postés 9813 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 - 3 juin 2013 à 08:34
Char Snipeur Messages postés 9813 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 - 3 juin 2013 à 08:34
A voir également:
- Incrementer une valeur dans un tableau matlab
- Tableau croisé dynamique - Guide
- Tableau word - Guide
- Tableau ascii - Guide
- Trier un tableau excel - Guide
- Comment imprimer un tableau excel sur une seule page - Guide
3 réponses
Char Snipeur
Messages postés
9813
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
3 octobre 2023
1 298
29 mai 2013 à 16:47
29 mai 2013 à 16:47
for i=1:m
if tab_conso(i,4)==13
z=z+50
endif
if tab_conso(i,4)!=1
tab_conso(i,7)= tab_conso(i,7)+z
end
end
ça devrait fonctionner ça.
if tab_conso(i,4)==13
z=z+50
endif
if tab_conso(i,4)!=1
tab_conso(i,7)= tab_conso(i,7)+z
end
end
ça devrait fonctionner ça.
kanwulf62
Messages postés
2
Date d'inscription
mercredi 29 mai 2013
Statut
Membre
Dernière intervention
1 juin 2013
1 juin 2013 à 12:50
1 juin 2013 à 12:50
merci de ton aide mais j'ai finalement trouver cette solution qui fonctionne
mais maintenant je dois faire pour 2H30 et j'ai un probleme avec les IF regardez plus bas SVP
z=0
% %Taille du tableau pour la boucle for
[m,n]=size(tab_conso)
% %Seul le nombre de ligne m t'interesse.
for i=1:m
if tab_conso(i,4)==12
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
else
tab_conso(i,7)= tab_conso(i,7)+z;
end
end
le 2eme code avec 2H30
nous avons tab conso 4 = heure
et tab cconso 5 = minute
et tab conso 7= la valeur du tableau a incrementer
donc j'ai essayer cela mais il se passe un probleme lors du resultat
et pas de probleme niveau compilation don je fais appel a vous
tab_conso0=tab_conso;
z=0
% %Taille du tableau pour la boucle for
[m,n]=size(tab_conso)
% %Seul le nombre de ligne m t'interesse.
for i=1:m
if tab_conso(i,4)==12
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
end
if tab_conso(i,4)==13
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
end
if tab_conso(i,4)==14
if tab_conso(i,5)<30
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
end
else
tab_conso(i,7)= tab_conso(i,7)+z;
end
end
cordialement
mais maintenant je dois faire pour 2H30 et j'ai un probleme avec les IF regardez plus bas SVP
z=0
% %Taille du tableau pour la boucle for
[m,n]=size(tab_conso)
% %Seul le nombre de ligne m t'interesse.
for i=1:m
if tab_conso(i,4)==12
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
else
tab_conso(i,7)= tab_conso(i,7)+z;
end
end
le 2eme code avec 2H30
nous avons tab conso 4 = heure
et tab cconso 5 = minute
et tab conso 7= la valeur du tableau a incrementer
donc j'ai essayer cela mais il se passe un probleme lors du resultat
et pas de probleme niveau compilation don je fais appel a vous
tab_conso0=tab_conso;
z=0
% %Taille du tableau pour la boucle for
[m,n]=size(tab_conso)
% %Seul le nombre de ligne m t'interesse.
for i=1:m
if tab_conso(i,4)==12
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
end
if tab_conso(i,4)==13
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
end
if tab_conso(i,4)==14
if tab_conso(i,5)<30
z=z+37;
tab_conso(i,7)= tab_conso(i,7)+z;
end
else
tab_conso(i,7)= tab_conso(i,7)+z;
end
end
cordialement
Char Snipeur
Messages postés
9813
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
3 octobre 2023
1 298
3 juin 2013 à 08:34
3 juin 2013 à 08:34
Rien compris.
Tu ne dit pas ce que tu veux obtenir.
Tu ne dit pas ce que tu veux obtenir.