Joe
Joe

Reputation: 351

Linear transformations performed on a coordinate grid in MATLAB

Is it possible to graphically represent linear transformations in MATLAB like the one shown below?

Graph Transformation Example

In particular, I'm looking for a way to represent the way a coordinate grid might become squished, stretched, or rotated after a matrix multiplication has been performed. I've tried using meshgrid(x,y) to plot the grid but I've been having trouble getting it to display properly. Ideally, it would be nice to see the way that the transformation acts on a unit square (and, if possible, to see the transformation being performed in a continuous fashion, where you can see the graphs morphing into each other). However, I'm willing to sacrifice these last two requirements.

Here is the code I have used so far:

x = -10:2:10;
y = -10:2:10;
[X,Y] = meshgrid(x,y);
plot(X,Y)

For some reason, only vertical lines have been plotted. (The documentation says it will display a square grid.)

Vertical lines

Upvotes: 0

Views: 441

Answers (1)

user158881
user158881

Reputation: 133

please read the plot doc. the problem is that what you are doing is trying to plot mash matrixes in a plot not by using mesh or something like that.

you may find this very helpful.

Upvotes: 2

Related Questions