matlab round
This is a topic that many people are looking for. thevoltreport.com is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, thevoltreport.com would like to introduce to you Rounding Functions in MATLAB. Following along are instructions in the video below:
So, next we are going to play around with rounding functions, and figure out with each one of them do. So, I know I keep saying this but you should totally do it. Like, pause the video, go play around with it go look at documentation. So, you would be like I want to know what round does, doc round. And youll be like, “Whoa there is a documentation for round thats insanity!” and youre like, “okay I got it.” Um, basically rounds up to the nearest positive integer. So, um, oh interesting, negative round down to the nearest. So, anyway, oh, for complex… Anyway, so, go ahead and play around with this and see how far you get, but basically, what you want to do is understand the difference tween round, fix, floor, and seal, and and kind of figure out what those do. So, to give you kind of a start… So, what do we have… We had round, fix, floor, and seal. So, start with some, like you know do some ones that you think youll know. So what happens when you round? You go -7.2, negative, I dont know, -3.5 -2.20 and then do them over here again. 2.2, 3.5 and 7.2 and see what you get, all right? So, um, theoretically, youve taken some time, and actually played around with this, but lets do it lets do round off X. Youd be like, “Okay well if I round
seven its closer to seven. If I round -3.5 its closer to -4. Were used to just kind of doing it that way. -2.2 rounds to -2. 0, 2, 4 & 7. So these shouldnt, theoretically, be too much of a shock. This uses, really kind of basic rounding. So, -3.5 is going to round. So, negative, and it said that in the documentation, but if its exactly 0.5 its going to round down to the more negative number. If its already negative, if its 3.5 or its a bit if its exactly 5, its going to round up to the next integer, which is what you see. So, if I change that to a 2.5 it would round up to a 3. It wouldnt round down to a 2. It round up to a 3. So, depending on your background in rounding that makes perfect sense or you just kind of have to think about it. Now fix… If I do fix and take round back out, if I do fix… All right, and basically one number changed. The thing that used to round down to -4 is now just at a 3. So this is a -2, and you know what I want to play with this a little bit more. Let me, let me fix that. Okay get it, because its fixed. Lets call this 7.7. So well see more of a change in 7.7 because then the 7.7 is
going to round down to an 8. Because its closer than an 8 to a 7 and so on so and so. So, thats still good but lets fix that now, back to fix. All right, now in this case two things changed. So, this was round. Round made the 7 go down to a -8 and the 3 go down to -4. Fix actually made it go to a 7, 3, 2 0 2 or 3 and a 7. So, what fix actually does, is fix truncates the the fractional value. So, it actually rounds towards zero. [toward zero so rounds towards? towards rounds toward zero] So, fix rounds towards zero. So, basically, truncates off the fractional part. Alright, floor, is going to do something a little bit different. Floor is actually kind of like a down, down function. Just let me copy these over to my little notepad. So, Im looking at these guys here, if I do floor… If I do the floor if any single one of these, So, the floor of -7.7, basically what thats going to do is its going to throw that down to the nearest integer. So, 7.7 is going to go down to -8, 3.5 is going to go down to -4, to 2.2 is gonna get down to -3 down to 2, down to 3, and down to 7. Not a big shock. Now for ceil. And, thats when well look at next.
Thats actually kind of the opposite. Its a ceiling function. So, that means its going to go up to the nearest integer. So, 7.7 is gonna go, -7 will go up to -7. This ones going to go up to -3, up to -2 this is already 0, up to 3. I had to think about that for a second. Up to 4, and up to 8. So, if youre not supposed to be at zero but if you go run this thats exactly what youre going to see. So, if I run the floor… So let me just call this rounded stuff. except it cant spell. Rounded stuff, fixed stuff, floor stuff, and ceiling stuff. So, now, I can actually compare what all these look like. So, theres my original values. Theyre rounded, it rounded everything toward the larger number, and in a case of the negative exactly 0.5 it rounded it down. So, 2, 4 and 8. Fixed it took off the decimal value. Floor always fell down, down, down, down, down, down and ceiling went up, up, up, up. Now, zero is all ready an integer. So just to make sure you got it: if I floor a number thats already an integer, it just stays there, if I ceiling a number thats already an integer, it just stays there. So, the fix, floor, ceiling, round that kind of stuff, those are only really interesting whenever were looking at non-fractional values.
tags:
MATLAB (Programming Language), round, fix, floor, ceil, ceiling
Thank you for watching all the articles on the topic Rounding Functions in MATLAB. All shares of thevoltreport.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.