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:
Problem with Xdata and Ydata scaling

Subject: Problem with Xdata and Ydata scaling

From: Camille Couzi

Date: 20 Aug, 2010 15:05:22

Message: 1 of 4

Hi,
I have a little problem with the use of XData. I am plotting and imagesc, for example for the matrix:
A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];

The default Xdata scaling would be: 0.5 1 1.5 2 2.5 3 3.5 4 4.5
(as size(A,1)=4

If I want to have (for example): 3 6 9 12, (only in with tick in the center of the squares, ie avoid the intermediate ticks and labels) how can I do?

I tried with:
x=[3 12];
imagesc(matriz,'XData',x)

but that doesn't work well, the ticks are not placed where I want.
Please, any help will be very appreciated!

Subject: Problem with Xdata and Ydata scaling

From: Grzegorz

Date: 20 Aug, 2010 16:04:05

Message: 2 of 4

"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <i4m5ji$30r$1@fred.mathworks.com>...
> Hi,
> I have a little problem with the use of XData. I am plotting and imagesc, for example for the matrix:
> A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];
>
> The default Xdata scaling would be: 0.5 1 1.5 2 2.5 3 3.5 4 4.5
> (as size(A,1)=4
>
> If I want to have (for example): 3 6 9 12, (only in with tick in the center of the squares, ie avoid the intermediate ticks and labels) how can I do?
>
> I tried with:
> x=[3 12];
> imagesc(matriz,'XData',x)
>
> but that doesn't work well, the ticks are not placed where I want.
> Please, any help will be very appreciated!

I think that this code is the solution of your problem:
A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];
x = 3:3:12
y = 1:3
imagesc(x,y,A)

Subject: Problem with Xdata and Ydata scaling

From: Camille Couzi

Date: 20 Aug, 2010 16:26:14

Message: 3 of 4

"Grzegorz " <gknor@o2.pl> wrote in message <i4m91l$jab$1@fred.mathworks.com>...
> "Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <i4m5ji$30r$1@fred.mathworks.com>...
> > Hi,
> > I have a little problem with the use of XData. I am plotting and imagesc, for example for the matrix:
> > A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];
> >
> > The default Xdata scaling would be: 0.5 1 1.5 2 2.5 3 3.5 4 4.5
> > (as size(A,1)=4
> >
> > If I want to have (for example): 3 6 9 12, (only in with tick in the center of the squares, ie avoid the intermediate ticks and labels) how can I do?
> >
> > I tried with:
> > x=[3 12];
> > imagesc(matriz,'XData',x)
> >
> > but that doesn't work well, the ticks are not placed where I want.
> > Please, any help will be very appreciated!
>
> I think that this code is the solution of your problem:
> A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];
> x = 3:3:12
> y = 1:3
> imagesc(x,y,A)

Hi Grzegorz,
Thanks for the reply, but it gives the same result as my example...: the axis is in fact scaled from 3 to 12, but it gives ticks for 2 4 6 8 10 12...
I need only ticks in the center of the squares, ie here 3 6 9 12, I don't want to see other ticks and labels... that make sense?
Thank you a lot

Camille.

Subject: Problem with Xdata and Ydata scaling

From: Steven_Lord

Date: 20 Aug, 2010 16:36:57

Message: 4 of 4



"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message
news:i4mab6$d99$1@fred.mathworks.com...
> "Grzegorz " <gknor@o2.pl> wrote in message
> <i4m91l$jab$1@fred.mathworks.com>...
>> "Camille Couzi" <camillecouzi@yahoo.fr> wrote in message
>> <i4m5ji$30r$1@fred.mathworks.com>...
>> > Hi,
>> > I have a little problem with the use of XData. I am plotting and
>> > imagesc, for example for the matrix:
>> > A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];
>> >
>> > The default Xdata scaling would be: 0.5 1 1.5 2 2.5 3 3.5 4 4.5 (as
>> > size(A,1)=4
>> >
>> > If I want to have (for example): 3 6 9 12, (only in with tick in the
>> > center of the squares, ie avoid the intermediate ticks and labels) how
>> > can I do?
>> >
>> > I tried with:
>> > x=[3 12];
>> > imagesc(matriz,'XData',x)
>> >
>> > but that doesn't work well, the ticks are not placed where I want.
>> > Please, any help will be very appreciated!
>>
>> I think that this code is the solution of your problem:
>> A=[ 5 6 4 8; 8 12 23 31;15 9 27 5];
>> x = 3:3:12
>> y = 1:3
>> imagesc(x,y,A)
>
> Hi Grzegorz,
> Thanks for the reply, but it gives the same result as my example...: the
> axis is in fact scaled from 3 to 12, but it gives ticks for 2 4 6 8 10
> 12...
> I need only ticks in the center of the squares, ie here 3 6 9 12, I don't
> want to see other ticks and labels... that make sense?

Then SET the XTick property of the axes. You may want to adjust the
XTickLabel property of the axes as well. See DOC SET for more information
about setting Handle Graphics properties.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for 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