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!