Hi There, A question about MATLAB. Is there any function by which we can find largest Integer upto a real number. I will better put up with an example. for example you have a real number 9.867 the larget integer less than this number is 9. How you get it? similarly smallest integer greater than this is 10 ! how to get that too? Any MATLAB function for this? Your help will be well appreciated. I couldn't figure out how/what to query dumb computers!! so asking intelligent human beings :) Any lead will be helpful. Cheers !! VPSA
In article <1143522417.678415.71590@g10g2000cwb.googlegroups.com>, "VPSA" <vpsanand@gmail.com> wrote: > Hi There, > > A question about MATLAB. Is there any function by which we can find > largest Integer upto a real number. I will better put up with an > example. for example you have a real number 9.867 the larget integer > less than this number is 9. How you get it? similarly smallest integer > greater than this is 10 ! how to get that too? Any MATLAB function for > this? > > Your help will be well appreciated. I couldn't figure out how/what to > query dumb computers!! so asking intelligent human beings :) > > Any lead will be helpful. > > Cheers !! > > VPSA --------------------- Yes, they are called 'floor' and 'ceil' respectively: floor(9.867) = 9 ceil(9.867) = 10 (Remove "xyzzy" and ".invalid" to send me email.) Roger Stafford
Thanks Mate !! You are a legend. Cheers ! :)
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message news:ellieandrogerxyzzy-2703062147150001@dialup-4.232.63.199.dial1.losangeles1.level3.net... > In article <1143522417.678415.71590@g10g2000cwb.googlegroups.com>, "VPSA" > <vpsanand@gmail.com> wrote: > >> Hi There, >> >> A question about MATLAB. Is there any function by which we can find >> largest Integer upto a real number. I will better put up with an >> example. for example you have a real number 9.867 the larget integer >> less than this number is 9. How you get it? similarly smallest integer >> greater than this is 10 ! how to get that too? Any MATLAB function for >> this? >> >> Your help will be well appreciated. I couldn't figure out how/what to >> query dumb computers!! so asking intelligent human beings :) >> >> Any lead will be helpful. >> >> Cheers !! >> >> VPSA > --------------------- > Yes, they are called 'floor' and 'ceil' respectively: > > floor(9.867) = 9 > ceil(9.867) = 10 I would also look into 'round' and 'fix' by typing in 'help round' and 'help fix' at the command line... Cheers! -- Vig
Vig, Thanks. This is another piece of useful information and is definately gonna help in future. i have done what you said, type help fix ... added to knowledge !! :) as in the case of number say 9.687 round and fix are pretty much the same as ceil and floor respectively. but what if the number is say, 9.34 !! I think they are useful in some other sense.
In article <ellieandrogerxyzzy-2703062147150001@dialup-4.232.63.199.dial1.losangeles1.level3.net>, ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote: > In article <1143522417.678415.71590@g10g2000cwb.googlegroups.com>, "VPSA" > <vpsanand@gmail.com> wrote: > > > A question about MATLAB. Is there any function by which we can find > > largest Integer upto a real number. I will better put up with an > > example. for example you have a real number 9.867 the larget integer > > less than this number is 9. How you get it? similarly smallest integer > > greater than this is 10 ! how to get that too? Any MATLAB function for > > this? > --------------------- > Yes, they are called 'floor' and 'ceil' respectively: > > floor(9.867) = 9 > ceil(9.867) = 10 -------------------- I just noticed that you said, "largest integer less than" and "smallest integer greater than". If you really meant "less than" as opposed to "less than or equal to", and "greater than" rather than "greater than or equal to", then you should use the following instead of the 'floor' and 'ceil' functions: -1-floor(-x) % <-- is the largest integer less than x 1-ceil(-x) % <-- is the smallest integer greater than x Note: Remember that all of these inequalities above are the algebraic kind of inequalities where, for example, -5 is less than -4. (Remove "xyzzy" and ".invalid" to send me email.) Roger Stafford