Home > Software engineering >  Is it possible to arrange only maximum limit of graph in Matlab?
Is it possible to arrange only maximum limit of graph in Matlab?

Time:02-16

I want to give a maximum value to my ylimit in a graph.

I know ylim command takes minimum and maximum value.

How to arrange maximum limit for y axis, without changing mimimum?

CodePudding user response:

You can't do that directly, but it's easy:

new_upper = 10; % desired new upper limit
yl = ylim; % store current limits
ylim([yl(1) new_upper]) % set current lower and new upper

If you prefer a single line you can use min (you can't index directly into the output of ylim):

ylim([min(ylim) new_upper])
  • Related