2
votes

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?

2

2 Answers

1
votes

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');
2
votes

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.