Rot90 | Matlab Video 23: Flipud, Fliplr, And Rot90 Functions

Sagar Patel

Subscribe Here





Matlab Video 23: Flipud, Fliplr, And Rot90 Functions


So our goal for this video is we’re going to use the flippety-flip. Lr and rotate 90 degrees function functions to derive Matrix P from a and then Matrix C from a so first of all, let me define those three functions and what they are so flip. Ud function accepts a matrix name and what it stands for is. Flip up and down what it will do is will flip a matrix upside down. Basically, so if you have row one two, three, four five, it will make a new matrix. That’s flipped so the row Five will be your new. Row one row four would be a new Row two Row. Three remain the same in this case and row four. I mean, Row two will be a new rule for and Row. One will be a new Row 5 so well. Just flip it upside down. The flip L/R function also accepts a matrix name in its parameters and then what the flip? Lr function stands for is flip left to right, so well imagined ourselves imaginary y-axi’s around here. What I would do is it’ll. Flip this entire matrix around that axis, so it will flip it. So this column, one two three four will be the new matrix would be column would have column four first and column three, then call them two and then column one. Now the are OT ninety function also accepts a matrix name in its parameters and what it stands for is rotate by 90 degrees. It will rotate a matrix for the, for instance, this matrix a ninety degrees counterclockwise, so that’s that goes through that goes from right to left basically, or rather left to right, so it goes like that counter clockwise so here we have welcome, We’re going to do an example problem, and that’s that we’re going to learn how to use this functions. So here we have matrix a of size five by four and our goal. Our first goal is to get matrix. P from matrix a now one thing before we move on that, you have to keep in mind. Is that if your new matrix, for instance here? B is a size four by five and matrix. A is a size five by four. Now, if you want to get Matrix B from matrix a using flip UT and flip L our function, you have to make sure that matrix. P is of the same size to use it since you. You want B and sub size four by five and you could want from a which is of size five by four, you cannot use flip UD and flip L are functions in this case, you have to use the rotate 90 functions, so the way ninety function the way you had to think the way you should think about it is if the dimensions flip, you have to use the rotate 90 degree function if they don’t if they remain the same, you can use either rotate 90 or flip left right and up and down. Okay, so now let’s write our code so here. B is assigned, rotate 90 and inside that we will send it back so it will create a new matrix. B that’s assigned, rotate ninety eight, meaning that it will take this matrix rotated by 90 degrees, and then it will assign it to B so here you see, our new matrix is what we want it for B, So it’s two five, six one four, just check two just to be sure. Okay, so it is what we wanted so the way I like to think about it is every time you do. Rotate 90 a what it will do is. I would keep an eye out for the lower-right element or any corner element. It can do, that’s fine too, but I like to keep an eye out on the lower-right element, and then every time you rotate 90 function, it moves from lower right to top right and then from top right to top left and then from top left to top. I mean, bottom left and then from bottom left. If you do it four times, that’s just not doing anything well. Go back to this position. So every time you use rotate 90 a for this matrix, A this four will go from initially. It starts here then once you do this. This four will move to the top-right corner as you can see right here. If you do it again, this four will move to the top-left corner up here and then off like this one right here, and then if we do it again, it’ll move down here. This four will move down here and the matrix will shift accordingly. So let’s do one more example with this here we have. CS assigned of five by four matrix. And as you can see that this C Matrix C and matrix a are up the same size. So in this case, we can use flip up down and flip left-right functions, so I will use both these functions and rotate 90 degrees function. In this case. You can’t directly do it. You have to use what’s called nesting of function, Which means you put a function inside a function. You can do it if we don’t want to nest. You have to do two lines of code if you want to nest functions, which is which is where I recommend doing, you can do it in one line of code, so what I would do here is rotate 90 since you see that the four has moved from here to top left corner, so you have to use rotate 90 degrees function twice, so I’ll put rotate 90 inside, rotate 90 and then I’ll put the matrix a so this in there. Rotate 98 What it will do is it will create a new matrix that looks like this matrix. B right here. And then it will take that matrix here. So imagine this is B. You are sending this instead, rotate 90 a. Because that’s what B is. Imagine, sending it be what it will do is. It will rotate this from here to top left corner right here. So if you run this, you see that you get matrix. C that contains elements for 7 to 8 1 9 75 And I’m assuming everything else is the same two. Now you can also use alcohol abuse. You can also use flip up down and flipped left/right function. And ya n flip left/right functions to do it. It does not matter if you put flip up down here or flip left, right, Because the end result will be the same so. I’ll run this and flip. I flip left, right, so you see that you get matrix? C you see is identical to matrix C. And that is how you would use these functions to move around elements in a matrix. So thank you for watching. See you next time.

0.3.0 | Wor Build 0.3.0 Installation Guide

Transcript: [MUSIC] Okay, so in this video? I want to take a look at the new windows on Raspberry Pi build 0.3.0 and this is the latest version. It's just been released today and this version you have to build by yourself. You have to get your own whim, and then you...

read more