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!