Add a second x-axis to a given multi-series plot
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
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!

댓글 수: 0
채택된 답변
  dpb
      
      
 2015년 10월 22일
        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.
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

