Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Karthik Brs
Karthik Brs am 22 Okt. 2015
Kommentiert: Karthik Brs am 27 Okt. 2015
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!

Akzeptierte Antwort

dpb
dpb am 22 Okt. 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.
  1 Kommentar
Karthik Brs
Karthik Brs am 27 Okt. 2015
Thank you for the response! I ended up using using a 3d plot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by