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:
How to set up axis max-min

Subject: How to set up axis max-min

From: Slawomir

Date: 26 Apr, 2012 13:36:07

Message: 1 of 5

Hello, how to define on 2D plot X and Y axes to be from interval -8:0.01:8?

x = -8:0.01:8;
y = -8:0.01:8;
size(x)
size(y)

c = sin(sqrt(x.^2+y.^2));
d = sqrt(x.^2+y.^2)
z = c/d
grid on
plot(z, '+b')

THANK YOU!

Subject: How to set up axis max-min

From: Slawomir

Date: 26 Apr, 2012 13:42:07

Message: 2 of 5

Sorry, it should be like that:


x = -8:0.01:8;
y = -8:0.01:8;
size(x)
size(y)

z = sin(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2)
grid on
plot(z, '+b')

But the question remains from above.

Subject: How to set up axis max-min

From: dpb

Date: 26 Apr, 2012 13:49:22

Message: 3 of 5

On 4/26/2012 8:42 AM, Slawomir wrote:
> Sorry, it should be like that:
>
>
> x = -8:0.01:8;
> y = -8:0.01:8;
> size(x)
> size(y)
>
> z = sin(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2)
> grid on
> plot(z, '+b')
>
> But the question remains from above.

doc axis

--

Subject: How to set up axis max-min

From: Steven_Lord

Date: 26 Apr, 2012 14:24:58

Message: 4 of 5



"Slawomir " <SlawomirBabicz@gmail.com> wrote in message
news:jnbj07$hkj$1@newscl01ah.mathworks.com...
> Hello, how to define on 2D plot X and Y axes to be from
> interval -8:0.01:8?
>
> x = -8:0.01:8;
> y = -8:0.01:8;
> size(x)
> size(y)
>
> c = sin(sqrt(x.^2+y.^2));
> d = sqrt(x.^2+y.^2)
> z = c/d

You want c./d here instead to perform elementwise division.

> grid on
> plot(z, '+b')

This line of code is the equivalent of:

plot(1:size(z, 2), z, '+b');

Explicitly specify the x coordinates at which you want z plotted instead:

plot(x, z, '+b')

Depending on the range spanned by z, you may also need to use AXIS.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: How to set up axis max-min

From: Slawomir

Date: 26 Apr, 2012 14:42:07

Message: 5 of 5

Steven_Lord, thank you, I needed that line. :)

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