rounding excel columns with Matlab
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Image Analyst
am 18 Apr. 2012
http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers
Antworten (1)
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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.
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!