Clear Filters
Clear Filters

Add a second x-axis to a given multi-series plot

1 view (last 30 days)
As can be seen in the figure below, the plot command gives us a graph of Sound Power(dB) Vs Frequency for different surfaces. I am required to add a second axis to the below plot such that the x-axis also includes the 'rpm'. I have a vector of 'rpm's' for all the frequencies. rpm and frequency are related. rpm = frequency/(time order*60). Currently my x-axis contains only the frequency. How can I add a second axis(rpm's) without crowding the current x axis(frequency)? Here is the code which I am using..
ord(y1).freq = transpose(ord(y1).dat(1,:));
ord(y1).rpm = ord(y1).freq/ord1(y1)*60;
ord(y1).total_lw = transpose(ord(y1).dat(2,:));
ord(y1).lw = transpose(ord(y1).dat(3,:));
ord(y1).lw2 = transpose(ord(y1).dat(4,:));
ord(y1).lw3 = transpose(ord(y1).dat(5,:));
figure;
% Plot for frequency and sound power
x = ord(y1).freq;
z1 = ord(y1).lw; z2 = ord(y1).lw2; z3 = ord(y1).lw3; z4 = ord(y1).total_lw;
plot(x,z1,x,z2,x,z3,x,z4,'--','Linewidth',1.5);
title(sprintf('%s for the time order %d',Method, ord1(y1)),'FontSize',16,'Fontweight','bold');
grid on
xlabel('Frequency Hz','FontSize',12,'Fontweight','bold');
ylabel('Schallleistung dB','FontSize',12,'Fontweight','bold');
legend('Surface1','Surface2','Surface3','Total Surface','location','southeast');
Thank you in advance!

Accepted Answer

dpb
dpb on 22 Oct 2015
See File Exchange AddTXaxis which does precisely what you're asking for altho I note it has an issue w/ new HG2 engine that may need some patches to work around.
Or do a search for plotxx on the FEX; there are quite a number of similar routines. Or, there's the section in the documentation under Line Plots on Using Multiple X- and Y-Axes that outlines the basic process.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!