MATLAB: Round to Nearest Multiple of 4. round If my calculation gives, a= 45, I want 44. Some example: 20 would be 20, 13 would be 12, 10 would be 12 or 8. How to round the number like this way? Best Answer a=45;k=4;b=k*round(a/k); Related SolutionsMATLAB: How can i round up all the numbers in this matrix (to make it look like the bottom line) https://www.mathworks.com/help/matlab/ref/ceil.html - ceil() does the job.a=[ 19.921920682316983 15.607883029893719 12.369945347943816 9.904715485705831 8.006173113714063 5.365552456501197 3.704171008046680 ];b=ceil(a)Gives:b = 20 16 13 10 9 6 4 MATLAB: Round to nearest odd integer I don't think so, but you could make your own:function S = round_odd(S)% round to nearest odd integer.idx = mod(S,2)<1;S = floor(S);S(idx) = S(idx)+1; Related QuestionHow to round number up to a specific number of decimal placesRound off to nearest 5 instead of 10How can i round numbers to multiple of any numberRounding elements in array to nearest 0.25Truncating a number without rounding
Best Answer