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

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Plotyy and linkprop problem

Asked by none on 6 Jul 2012

hello.

I type:

T = 1000;
time = 1: T;
x1 = rand(T,1);
x2= rand(T,1);
myTime = {...
'08:00'  
'08:10'  
'08:20'  
'08:30'  
'08:40'  
'08:50'  
'09:00'  
'09:10'  
'09:20'  
'09:30'  
'09:40'  
'09:50'  
'10:00'  
};
[AX,H1,H2] = plotyy(time,x1, time,x2);
linkprop(AX,{'Xlim','XTickLabel','Xtick'});
set(AX(1), 'XTickLabel', myTime);

However, I see my time axis only runs from 0800 to 0940 not 1000 as I wish it to.

Any suggestions as to what I have done wrong?

thank you!

0 Comments

none

Products

No products are associated with this question.

2 Answers

Answer by none on 6 Jul 2012
Accepted answer

solved:

T = 1000;
time = 1: T;
x1 = rand(T,1);
x2= rand(T,1);
myTime = {...
'08:00'  
'08:10'  
'08:20'  
'08:30'  
'08:40'  
'08:50'  
'09:00'  
'09:10'  
'09:20'  
'09:30'  
'09:40'  
'09:50'  
'10:00'  
};
[AX,H1,H2] = plotyy(time,x1, time,x2);
linkprop(AX,{'Xlim','XTickLabel','Xtick'});
t3 = linspace(0, T, size(myTime,1));
set(AX(1), 'XTick', t3);
set(AX(1), 'XTickLabel', myTime);

0 Comments

none
Answer by S. M. Mehdi Ansarey M. on 19 Nov 2012

a smaller version but with the same idea as above solution:

T = 1000;

time = 1: T;

x1 = rand(T,1);

x2= rand(T,1);

myTime = {... '08:00' '08:10' '08:20' '08:30' '08:40' '08:50' '09:00' '09:10' '09:20' '09:30' '09:40' '09:50' '10:00' };

[AX,H1,H2] = plotyy(time,x1, time,x2);

set(AX, 'XTick', linspace(time(1), time(end), 13))

linkprop(AX,{'Xlim','XTickLabel','Xtick'});

set(AX(1), 'XTickLabel', myTime);

0 Comments

S. M. Mehdi Ansarey M.

Contact us