Maximizing Plot Clarity: Adding Formatting Without Clearing in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter freezer
  • Start date Start date
  • Tags Tags
    Plot
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
freezer
Messages
75
Reaction score
0
I am creating a plot in a for loop adding each iteration to the plot in matlab. This part works fine but after the for loop, i am trying to format the title and axis and that is clearing the plot. I can add the legend without it clearing. I also tried hold all but that did not work either. Any tips to get the formatting addition to not clear the plot?

this is the plot that is in the for loop:

plot(W,M,'color',[1-ii/10 ii/10 1]); hold on Then after the for loop:
Code:
axis([0 2500 0 1.1]) 
title('BPFs') 
xlabel('Frequency (Hz)'); 
ylabel('Magnitude'); grid on

I can add the legend without it clearing if i comment out the code above.

Code:
legend(['F_c= ',int2str(fb(1)),' Hz'],['F_c= ',int2str(fb(2)),' Hz'],... % Creates the legend of the plot.
['F_c= ',int2str(fb(3)),' Hz'],['F_c= ',int2str(fb(4)),' Hz'],...
['F_c= ',int2str(fb(5)),' Hz'],['F_c= ',int2str(fb(6)),' Hz'],...
['F_c= ',int2str(fb(7)),' Hz'],['F_c= ',int2str(fb(8)),' Hz']);
 
Physics news on Phys.org
Sorry, never mind... had my axis scale off and it was just shifted off plot..