- #1
cookiemnstr510510
- 162
- 14
- Homework Statement
- The area of a rectangle is length times width. Find the areas of rectangles with lengths of 1,3, and 5cm and with widths of 2,4,6 and 8cm. (you should have 12 answers)
- Relevant Equations
- meshgrid command in MATLAB
Hello All,
So I know how to solve this problem, but I don't understand it.
I first create a vector for length and width:
L=[1 3 5]
W=[2 4 6 8]
I then use meshgrid to make my L and W vectors have the same dimensions.
[X,Y]=meshgrid(L,W)
Then multiply X and Y together using array multiply (not matrix multiply)
X.*Y
This seems like magic to me.
I know Meshgrid defines X so every row is L, and each of Y's columns is W. I also know that the dimensions of both X and Y have rows equal to length(W) and columns equal to length(L).
I get all that and accept what Meshgrid does internally, I just wonder if there is a logical sort of "proof" of how we get the correct answer from it. It seems a bit convoluted to me as a beginner, and difficult to think about.
Any help is appreciated!
Thanks
So I know how to solve this problem, but I don't understand it.
I first create a vector for length and width:
L=[1 3 5]
W=[2 4 6 8]
I then use meshgrid to make my L and W vectors have the same dimensions.
[X,Y]=meshgrid(L,W)
Then multiply X and Y together using array multiply (not matrix multiply)
X.*Y
This seems like magic to me.
I know Meshgrid defines X so every row is L, and each of Y's columns is W. I also know that the dimensions of both X and Y have rows equal to length(W) and columns equal to length(L).
I get all that and accept what Meshgrid does internally, I just wonder if there is a logical sort of "proof" of how we get the correct answer from it. It seems a bit convoluted to me as a beginner, and difficult to think about.
Any help is appreciated!
Thanks