Hello,
In my MWE below, I am plotting 4 graphs. I am trying to get graph (c) and (d) to show up with the x-axis as floating numbers, however I do not display the correct values for the x-axis points. If I put a break point in my program at line 23, and step through the program, it works without any problems. Can you tell me why I get an incorrect x-axis display if the program is run normally?
Here is my code:
clear;clc;x1 = linspace(100, 10^7, 100);y1 = rand(100,1);y2 = rand(100,1);y3 = randi([-100,100],100,1);subplot(2,2,1);plot(x1, y1);grid on;title('(a) Silent Carrier (No Modulation)');xlabel('Frequency (MHz)'); ylabel('Amplitude');subplot(2, 2, 2);plot(x1, y1);grid on;title('(b) Spectrum with Modulation');xlabel('Frequency (MHz)'); ylabel('Amplitude');subplot(2,2,3);semilogx(x1, y2);grid on;title('(c) SSB Spectrum (Silent Carrier - NO Modulation)');xlabel('Frequency Offset (Hz)'); ylabel('Phase Noise (dBc/Hz)');curtick = get(gca, 'XTick');set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));subplot(2,2,4);semilogx(x1, y3);grid on;curtick = get(gca, 'XTick');set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));title('(d) SSB Spectrum with Modulation');xlabel('Frequency Offset (Hz)'); ylabel('Phase Noise (dBc/Hz)');
This is what I get for graphs (c) and (d):
and the "curtick" only has values [1 100000 10000000000.0000].
When it should be like:
I've recently found that if I leave the figure window open, in full screen, and re-run the program, it works. If I close the figure widow, and let it open up with the program, it comes in looking like the first figures.
Best Answer