Afficher commentaires plus anciens
Consider the following vector V=[10,4,7,-8,-3,-12] Write an m file in MATLAB that doubles the elements that are negative and are divisible by 2 and/or 4, and raise to the power of 2 the elements that are positive but greater than 6.
My solution is as above, however I have not managed to run it yet...
function V(i)=[10,4,7,-8,-3,-12];
for i=1:1:6;
if [V(i)<0 | mod(V(i),2)==0 | mod(V(i),4)==0],
V(i)=V(i)*2;
end
if [V(i)>0 & V(i)>6],
V(i)=i*i;
end
V(i);
I kindly request your help. Thank you...
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Adding custom doc dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!