user2260180
user2260180

Reputation: 275

Matlab plotyy and semilogx

I need to plot two curves which share the same x axis but not the y. This can be achieved with plotyy.

However, the common x axis is to use the log scale, hence i would need to use semilogx.

I have tried the hold on, did not work.

My problem is that one can not combine plotyy with semilogx. Is there a solution to this vexing problem?

Upvotes: 2

Views: 5640

Answers (2)

tmpearce
tmpearce

Reputation: 12693

You can use the axes property XScale

set(gca,'XScale','log')

to change the axis scale to from 'linear' (default) to 'log'. (The other axes work the same way).

With multiple sets of axes, you can find the handles of the children of the figure, and set this property on all of them.

Upvotes: 2

bla
bla

Reputation: 26069

Here's an example of how to do it:

t = 0:900; A = 1000; a = 0.005; b = 0.005;
z1 = A*exp(-a*t);
z2 = 2*A*exp(-a*t/2);
plotyy(t,z1,t,z2,'semilogx','semilogx');

Upvotes: 1

Related Questions