Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Drawing a 2d square in math lab

Subject: Drawing a 2d square in math lab

From: sbose27@gmail.com

Date: 17 Nov, 2007 01:20:21

Message: 1 of 2

I'm trying to render a square object in math lab using matrix values
and am unsure on how to go about this. Is there a specific command to
draw this easily using matrix values. For example:

A = [-1 -1 1 1; -1 1 1 -1]

    -1 -1 1 1
    -1 1 1 -1

Is there a command to map each vector as a corner point for a square
in a graph. If this square can be generated is there a way to view
multiple squares in the same graph?

Thanks for any help.

Subject: Drawing a 2d square in math lab

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 17 Nov, 2007 17:00:34

Message: 2 of 2

In article <a8386a05-3dce-40c7-80ce-4a1e94f211b6@c30g2000hsa.googlegroups.com>,
 <sbose27@gmail.com> wrote:
>I'm trying to render a square object in math lab using matrix values
>and am unsure on how to go about this. Is there a specific command to
>draw this easily using matrix values. For example:

>A = [-1 -1 1 1; -1 1 1 -1]

> -1 -1 1 1
> -1 1 1 -1

>Is there a command to map each vector as a corner point for a square
>in a graph.

If you only have the four points, then you will need to use patch().
If you close the square yourself (repeat the original point at the
end so it knows to draw back to the origin) then you can use plot()
or line().

> If this square can be generated is there a way to view
>multiple squares in the same graph?

Yes. patch() and line() do not erase the current plot. plot()
allows you to list several coordinate lists in the same call, and
you can always use 'hold on' and make several plot() calls.
--
   "Okay, buzzwords only. Two syllables, tops." -- Laurie Anderson

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us