Mary Star
Mary Star

Reputation: 375

Appearance of numbers

I have written a code in matlab in which N is the vector N=[25; 50; 100; 200; 400]

The values of E are the following:

 E(1)= 0.010572 
 E(2)= 0.002634 
 E(3)= 0.000658 
 E(4)= 0.000164 
 E(5)= 0.000041 

I want to create a loglog graph of E and N.

To do that I wrote the following code:

  axis([min(N) max(N) min(E) max(E)]); 
  loglog(N, E, 'red')
  xlabel('N')
  ylabel('E')
  grid on

I get the following output: enter image description here

What can I do so that at the N-axis, there appear all the possible values of N?

Upvotes: 1

Views: 33

Answers (1)

Add set(gca,'xtick',N); after your plot command.

result

As you can see, this will specify the xticks to be precisely where your N data are. You could also add these numbers to the automatic ones: for this you should issue

ticks=get(gca,'xtick');
set(gca,'xtick',union(ticks,N));

Upvotes: 3

Related Questions