Making all Elements in Matrix Even.
Show older comments
I want o make all the elements in the Matrix even.
For eg.
if the matrix is a=[53, 59, 61, 87],
The output matrix b should be b=[54, 60, 62, 88].
I have tried this,
for l=1:length(a)
if mod(l,2)==1
l=l+1;
end
b=(:,l);
end
but it doesnt work.
Any help would be appreciated.
Thanks.
Accepted Answer
More Answers (1)
a=[53, 59, 61, 87] ;
iwant = a+mod(a,2)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!