How can I replace roundn?

My Matlab version is R2014a, I need a replacement for the function roundn that was common in the matlab previous versions, but not more recognized for the 2014 version. Part of my code is: drawLine([0 roundn(max(z1),2)+100], [0 min(z1)]); hold on; ps: z1 is 2601x1double

 Accepted Answer

MATLAB has always had a round function, recently incorporating the functionality of roundn from the MApping Toolbox.
You can create your own version with this anonymous function:
roundn = @(x,n) 10.^n .* round(x/10.^n);
It produced the same answer for the same input as the example in the documentation for it when I tested it, so it should be a seamless replacement.

2 Comments

Thank you Star Strider, the code is fixed!
My pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Signal Processing Toolbox in Help Center and File Exchange

Tags

Asked:

on 22 Jul 2015

Commented:

on 22 Jul 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!