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!