Effacer les filtres
Effacer les filtres

while/for loop

1 vue (au cours des 30 derniers jours)
Arashdeep Dhillon
Arashdeep Dhillon le 17 Avr 2019
Réponse apportée : dpb le 17 Avr 2019
So I have a vector V of which i found its length and i hv used fprintf to print the statement. Now how do i create a new vector from that doubles the elements that are positive and divisible by 3 or 5, raises to the power of 3 the elements that are negative but greater than -5 and excludes all other elements. I know i have to use a for or while loop for this but how would i do so?

Réponses (1)

dpb
dpb le 17 Avr 2019
"know i have to use a for or while loop..."
Not with Matlab, no! Use Logical indexing (link) as illustrated...

Catégories

En savoir plus sur Loops and Conditional Statements 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!

Translated by