Can you label multiple figures with the same x & y labels with just one line of code?
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I have some code that looks like this:
 if figs==4
      figure
      plot(X(:,1:7))
      xlabel('Data point number')
      ylabel('Amplitude')
      figure
      plot(X(:,8:14))
      xlabel('Data point number')
      ylabel('Amplitude')
      figure
      plot(X(:,15:22))
      xlabel('Data point number')
      ylabel('Amplitude')
      figure
      plot(X(:,23:30))
      xlabel('Data point number')
      ylabel('Amplitude')
  end
Is there some way I can label the x & y labels for all the figures the same thing, with one line of code, instead of having to write the labels out each time I have a figure.
1 commentaire
  Image Analyst
      
      
 le 7 Mar 2015
				Here is the original question, for when Mary overwrites it with gibberish:
I have some code that looks like this:
 if figs==4
      figure
      plot(X(:,1:7))
      xlabel('Data point number')
      ylabel('Amplitude')
      figure
      plot(X(:,8:14))
      xlabel('Data point number')
      ylabel('Amplitude')
      figure
      plot(X(:,15:22))
      xlabel('Data point number')
      ylabel('Amplitude')
      figure
      plot(X(:,23:30))
      xlabel('Data point number')
      ylabel('Amplitude')
  end
Is there some way I can label the x & y labels for all the figures the same thing, with one line of code, instead of having to write the labels out each time I have a figure.
Réponses (1)
  Star Strider
      
      
 le 22 Fév 2015
        
      Modifié(e) : Star Strider
      
      
 le 22 Fév 2015
  
      See if this does what you want:
axlbl = @(h) [xlabel(h, 'Data point number'); ylabel(h, 'Amplitude')];
figure
plot(rand(1,10), rand(1,10))
axlbl(gca);
figure
plot(rand(1,20), rand(1,20))
axlbl(gca);
The gca function ‘gets’ the ‘current axis’ handle, that is then passed to the function and used by the xlabel and ylabel functions to put the labels on the correct axes.
0 commentaires
Voir également
Catégories
				En savoir plus sur Axis Labels dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


