rounding excel columns with Matlab
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2012-4-18
http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers
回答(1 个)
Walter Roberson
2012-4-18
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 个评论
Walter Roberson
2012-4-18
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!