rounding excel columns with Matlab
4 views (last 30 days)
Show older comments
I need to write a code that can round any number to any required digit from an excel document. Basically, in the excel document, if you find 10 in the second column, then round the value of the first column to the nearest 10. If you find 0.001 in the second column,then round the value of the first column to the nearest 0.001
The problem is, is that I'm not allowed to use any built in functions. (such as round, ceil, floor, fix, max, min, find, etc...) I'm ONLY allowed to use length, size, relationship operators {<> ~ =}, logical operators ({I,&}, if, for, while, switch.
1 Comment
Image Analyst
on 18 Apr 2012
http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers
Answers (1)
Walter Roberson
on 18 Apr 2012
It is not possible to do that operation with those restrictions.
- those operations are not able to read an excel document
- you need to use arithmetic operations to do the rounding. Even the Peano Postulates require the operation of adding 1.
- it is not actually possible to round binary numbers to multiples of .1 or .01 or .001 etc.
2 Comments
Walter Roberson
on 18 Apr 2012
xlswrite() cannot execute commands in excel: it can only write cells, not execute anything.
MATLAB cannot execute commands in excel without use of actxserver() which is not on your list of allowed functions. Also, actxserver() is only supported in MS Windows.
It is not possible to do the rounding using the list of allowed functions you indicate -- not with any program that would fit within the maximum memory that can be allocated in MATLAB (2^48 bytes). More than 2^67 bytes of code would be required to do the rounding with only the functions on your allowed function list.
See Also
Categories
Find more on Spreadsheets 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!