" for element in List" - (simple problem)
49 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mike Owl
le 11 Nov 2020
Réponse apportée : Mathieu NOE
le 13 Nov 2020
Hi everyone,
i am new to programming but i know that you can write in Python something like this:
x3 = [5, 4, -3, -2]
j = 4
for element in x3:
if element > 0:
j =+ 1
print (j)
How to write those bold lines in Matlab?
I searched in google but could't find anything.
Thanks a lot!
0 commentaires
Réponse acceptée
Mathieu NOE
le 13 Nov 2020
hello Mike
this is it
please check if the display of j is in the inner our the outer loop
x3 = [5, 4, -3, -2]
j = 4
for ci = 1:length(x3)
if x3(ci) > 0
j = j +1;
disp(j)
end
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!