Matlab M-File
显示 更早的评论
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...
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Adding custom doc 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!