Asked by Zeynab Mousavikhamene
on 19 Aug 2019 at 6:16

I have a series of X and Y that some of Ys might be inf. Ys are changing in each loop there might be inf in them (more than one or none).

When I plot with plot(X,Y) function, it deos not show inf values. Any suggestion?

Answer by Walter Roberson
on 19 Aug 2019 at 6:44

plot(X, min(Y, ValueYouWantPlottedInsteadOfInf))

Walter Roberson
on 2 Sep 2019 at 9:57

That will not happen with Adam's sample code: Adam only uses ytickLabels as a variable.

Zeynab Mousavikhamene
on 2 Sep 2019 at 20:53

would you please explain more?

Walter Roberson
on 2 Sep 2019 at 21:19

Adam posted

y = randi(1e10, 1,100);

y(randi(100,1,15)) = inf;

plot(min(y, 2e10), 'o')

set(gca,'ytick',0:2e+09:2e10)

ytickLabels = get(gca,'YTickLabel');

ytickLabels{end} = 'inf x10^{10}';

set(gca, 'YTickLabel', ytickLabels)

His line

ytickLabels = get(gca,'YTickLabel');

creates a variable named ytickLabels. His line

ytickLabels{end} = 'inf x10^{10}';

then changes the last label to that particular string.

Then the line

set(gca, 'YTickLabel', ytickLabels)

tells MATLAB to change the YTickLabel property of the axes to the value stored in the variable ytickLabels

Adam's code does not attempt to use ytickLabels as a function. His code cannot generate the error message you indicate,

Cannot find an exact (case-sensitive) match for 'ytickLabels'

Please post a copy of the code you are using that generates that error message.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Adam Danz (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/476643-how-to-plot-a-series-of-numbers-which-some-of-them-are-inf#comment_736542

## Adam Danz (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/476643-how-to-plot-a-series-of-numbers-which-some-of-them-are-inf#comment_736798

## Zeynab Mousavikhamene (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/476643-how-to-plot-a-series-of-numbers-which-some-of-them-are-inf#comment_741253

## Adam Danz (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/476643-how-to-plot-a-series-of-numbers-which-some-of-them-are-inf#comment_741340

Sign in to comment.