Question

I would like to plot a graph in MATLAB but it displays x-axis as x10^6 ! How can I make it display it 10 000 000 ? See image below.

enter image description here

    frequency=[9999445,9999475,9999500,9999517,9999543,9999562,9999580,9999604,9999626,9999647,9999668,9999688,9999705,9999730,9999755,9999780,9999800,9999830,9999847,9999862,9999883,9999900,9999920,9999930,9999950,9999985,9999994,10000000,10000010,10000018,10000026,10000032,10000039,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045,10000045];
 temperature=[283,293,299,303,306,309,312,315,318,320,323,326,328,330,333,336,338,342,343,345,348,350,352,353,353,357,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354];
 time=[1:10:540]


 %plot(frequency)
 %figure,plot(temperature)

 figure,plot(frequency,temperature);
Was it helpful?

Solution

You can use set function on the XTickLabel property of the current axis.

An example is this:

x=[999 1000 1001 1002 1003];
y=3*x;
plot(x,y);
set(gca, 'XTick', x, 'XTickLabel', sprintf('%4.0f|', x));

enter image description here

in your case you can do this:

x=linspace(min(frequency),max(frequency),5);
figure,plot(frequency,temperature);
set(gca, 'XTick', x, 'XTickLabel', sprintf('%7.0f|', x));

enter image description here

you can change the 5 value to have more or less ticks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top