Error using 'YLim' for NEGATIVE Values (in plot\gca\YLim)

8 views (last 30 days)
Hello,
Please assist in getting below issue resolved.
We intend to define NEGATIVE values in Ylim parameter in gca for plotting purpose.
Sincerely,
A
*> A. TASK:*
1. Plot NEGATIVE VALUES ranging from -50 to -30. (-50 : -30)
2. In plotted figure, Demonstrate Y-Axis range from (-60 : -10)
*> B. ERROR:*
When YLim is used, following error is received:
"
Subscript indices must either be real positive integers or logicals.
Error in YTickIssue (line 11)
ax1.YLim([-60 -20]); "
*> C. CODE:*
"
x = [1:1:5];
y = [-36,-32,-46,-35,-37];
plot(x,y);
ax1 = gca;
ax1.YLim([-60 -20]);
"

Answers (1)

Star Strider
Star Strider on 9 Jun 2016
That is not the correct way to set the YLim property.
Try this instead:
ax1.YLim = [-60 -20];

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!