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:
XLABEL.

Subject: XLABEL.

From: Marcus Vinicius Pereira de Souza

Date: 28 Mar, 2008 03:13:02

Message: 1 of 4

Dear all,
I need to plot a graphic where xlabel is variable. Example:

X=[1 2 3;4 5 6;7 8 9];

Y=[10 20 30;40 50 60;70 80 90];

K=[];
M=[];

[m,n]=size(X);

for i=1:m
    for j=1:n
        if i >= j
           K=[K; X(i,j) Y(i,j)]
           M=[M; i j]
        end
   end
end

bar(K)

I need to put the labels on the bar graphic (to this
example):
M1-M1 M2-M1 M2-M2 M3-M1 M3-M2 M3-M3

Do anyone help me?
Thanks a lot!

Subject: XLABEL.

From: Sven

Date: 28 Mar, 2008 07:01:35

Message: 2 of 4

"Marcus Vinicius Pereira de Souza" <mvinic@hotmail.com>
wrote in message <fshnnu$bfs$1@fred.mathworks.com>...
> Dear all,
> I need to plot a graphic where xlabel is variable. Example:
>
> X=[1 2 3;4 5 6;7 8 9];
>
> Y=[10 20 30;40 50 60;70 80 90];
>
> K=[];
> M=[];
>
> [m,n]=size(X);
>
> for i=1:m
> for j=1:n
> if i >= j
> K=[K; X(i,j) Y(i,j)]
> M=[M; i j]
> end
> end
> end
>
> bar(K)
>
> I need to put the labels on the bar graphic (to this
> example):
> M1-M1 M2-M1 M2-M2 M3-M1 M3-M2 M3-M3
>
> Do anyone help me?
> Thanks a lot!
>


Hi Marcus,

Do you mean XTickLabels instead of xlabel?
Running the following command after you call "bar" will give
what (I think) you want.

set(gca,'XTickLabel',{'M1-M1','M2-M1','M2-M2','M3-M1','M3-M2','M3-M3'})

Cheers,
Sven.

Subject: XLABEL.

From: Marcus Vinicius Pereira de Souza

Date: 28 Mar, 2008 13:25:04

Message: 3 of 4

Dear Sven,
Thanks a lot!
By the way, I need to put the labels automatic because my
X (Y) real matrix has size 12 x 12!
Then I have 64 elements!
Seen what I have done:


X=[1 2 3;4 5 6;7 8 9];

Y=[10 20 30;40 50 60;70 80 90];

K=[];
M=[];
[m,n]=size(X);

for i=1:m
    for j=1:n
        
       
        if i > j
           K=[K; X(i,j) Y(i,j)];
           M=[M; i j];
           bar(K)
           a=num2str(i);
           b=num2str(j);
           set(gca,'XTickLabel',{'M{a}-M{b}'})

        end
   end
end

I would like to plot one (8 x 8) subplots too!!
Best regards,
Marcus Vinicius

Subject: XLABEL.

From: Yuri Geshelin

Date: 28 Mar, 2008 14:51:02

Message: 4 of 4

"Marcus Vinicius Pereira de Souza" <mvinic@hotmail.com>
wrote in message <fsirjf$42r$1@fred.mathworks.com>...
> Dear Sven,
> Thanks a lot!
> By the way, I need to put the labels automatic because my
> X (Y) real matrix has size 12 x 12!
> Then I have 64 elements!
> Seen what I have done:
>
>
> X=[1 2 3;4 5 6;7 8 9];
>
> Y=[10 20 30;40 50 60;70 80 90];
>
> K=[];
> M=[];
> [m,n]=size(X);
>
> for i=1:m
> for j=1:n
>
>
> if i > j
> K=[K; X(i,j) Y(i,j)];
> M=[M; i j];
> bar(K)
> a=num2str(i);
> b=num2str(j);
> set(gca,'XTickLabel',{'M{a}-M{b}'})
>
> end
> end
> end
>
> I would like to plot one (8 x 8) subplots too!!
> Best regards,
> Marcus Vinicius
>

Hi,

Nice plot. Normally, to make a plot like this a
presentation quality, you also need to do

set(gca,'fontweight','bold','fontsize',m)

where m is at least 16.

Yuri

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