How to graph three functions on the same plot. Two need a log scale y axis, other needs a linear scale.
2 views (last 30 days)
Show older comments
First I'll describe the system I am trying to model because I think there might be something tricky I'll need to do.. Also, I apologize that this may be confusing with all my random variables, but I'll try to describe a few quick before I start.
Side note, I use ode45 to integrate the density functions and the times used and integration results are stored into T and Ne respectively.
Ne, Ne2: electron densities, 1x1 cell with array type double
T, T2: Time, 1x1 cell with array type double
offset: used to center around 0
It(t): gaussian pulse (t is length of pulse in time)
var: normalization factor of pulse so it appears on same order as densities
density,density2: grab the final value out of the density cells to create the y limit of the log scale.
I am trying to model electron density versus time due to an incoming ultrashort laser pulse. I have two functions representing the full density, and one representing only one term of the density equation. Lastly, I want to show the gaussian pulse on the same plot as these densities.
The density functions will need a log scale, the pulse needs a linear scale. If I plot it like this,
plot(T{1}-offset,Ne{1},'r',T2{1}-offset,Ne2{1},'g',t-offset,var*It(t),'b')
I see only the full density and the gaussian pulse since the other term, Ne2, is a few orders of magnitude smaller. From here I've tried many different options and I have two different ones that sort of work. The first,
plotyy(T{1}-offset,Ne{1},t-offset,var*It(t),'semilogy','plot')
ylim([density2/100 density*10])
hold all
semilogy(T2{1}-offset,Ne2{1},'b')
works almost perfect except the x axis is no longer aligned. The point is to have the densities 0 time spot aligned with the 0 time spot of the pulse. In my other attempt,
semilogy(T{1}-offset,Ne{1},'r',T2{1}-offset,Ne2{1},'g')
ylim([density2/100 density*10])
hold all
semilogy(t-offset,var*It(t),'b')
the densities and pulse align, but the pulse is also changed to a log scale and no longer appears gaussian.
I hope someone can follow what I am trying to do and I greatly appreciate any help or advice!
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!