简体   繁体   中英

MATLAB: X-axis plotting out of range

I have x stops at 0.5*1.0e-04 but the plot plots through it to 0.6*1.0e-04 . How to deal with this out of range error? I try to plot real(y) instead but it does not help.

x = 1.0e-04 *[0 0.050 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000];
y = [2.0000 + 0.0000i   1.6096 + 0.0000i   1.5986 + 0.0000i   1.5903 - 0.0000i...
    1.5842 - 0.0000i   1.3794 - 0.0000i   1.5775 - 0.0000i   1.5790 - 0.0000i...
    1.5827 - 0.0000i   1.6867 - 0.0000i   1.5882 - 0.0000i];
figure(1)
plot(x, y,'-b','LineWidth',2); %plot(x, real(y),'-b','LineWidth',2);

在此处输入图片说明

It has to do with Matlab formatting your output. Try this command after you are done plotting:

axis tight;

Alternatively, you can manually set the axis limits as such:

xlim = [0,0.5*1.0e-04] 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM