When I execute the following:

`a = [1 2 3 4 100];b = [1 2 3 4 NaN];plot(a,b)`

I get a figure where the x-axis goes from 1 to 100. I want the x-axis to only show from 1 to 4 since there is really no x data out of the 1 to 4 range.

Skip to content# MATLAB: Are the axis limits set based on x-values that correspond to NaN y-values in the PLOT function in MATLAB 7.10 (R2010a)

###### Related Question

MATLAB

When I execute the following:

`a = [1 2 3 4 100];b = [1 2 3 4 NaN];plot(a,b)`

I get a figure where the x-axis goes from 1 to 100. I want the x-axis to only show from 1 to 4 since there is really no x data out of the 1 to 4 range.

- Do I not get any YTick marks on the semilogy PLOTYY axis in MATLAB 7.5 (R2007b)
- How to select a specific section of a 3D plot and show this selection in a new plot in MATLAB 7.10 (R2010a)
- Do I receive a “Maximum variable size” error when using the CLABEL function in MATLAB 7.0.4 (R14SP2)
- How to make user defined x-values with corresponding y-values
- Filtering values from a curve
- Is the upper limit of the Y-axis in the loglog plot wrong, after I attempt to set it using handle graphics
- Do the plots from BAR cover up the y-axis in MATLAB 7.10 (R2010a)

## Best Answer