How to plot unit square using single matrix, to apply transformation matrices onto it.

7 次查看(过去 30 天)
I am attempting to make a live script that demonstrates the effect of transformation matrices by showing its affect on the plotted unit square. Is it possible to plot a unit square using just a single matrix, such that transformation matrices can be applied to it and reflected in the plot? I am able to plot a unit square using x and y row vectors but not together. I am unsure if plot() is even the best way to go about this, any help would be appreciate it.
A = [0 0 1 1 0;
0 1 1 0 0]
plot(A)
x = [0 0 1 1 0]
y = [0 1 1 0 0]
plot(x,y)

回答(1 个)

Walter Roberson
Walter Roberson 2019-10-17
Is it possible to plot a unit square using just a single matrix, such that transformation matrices can be applied to it and reflected in the plot?
All of the plotting routines that I can think of in MATLAB want separated X and Y.
There are two ways to proceed:
  1. Put the separated X Y together in a matrix, apply the transform matrix, pull apart the results and plot. This will permit you to demonstrate the transformed coordinates to the user.
  2. create a hgtransform group. plot() the separated X Y parented to the hgtransform group. Then each time you can apply a transform matrix by change the Matrix property of the hgtransform. This will easily show the results of the transform matrix, but will not as easily permit you to display the transformed coordinates.

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by