필터 지우기
필터 지우기

Unable to set the scale fro -inf to inf

조회 수: 3 (최근 30일)
Raghav Rathi
Raghav Rathi 2023년 1월 13일
댓글: Sulaymon Eshkabilov 2023년 1월 13일
Hi,
I am trying to plot 2 arrays but I am not getting the expected result. I am sure I am making some mistake but I am unable to identify it.
x = [1 0.93 1 0.96 1 1 1 0.86];
snr = [Inf 9 -0.539 -4.98 -7.9 -10.08 -11.83 -13.28];
plot(snr,x)
ylim([0 1])
xlim([-inf inf])
Firstly, the plot is missing the value at 'inf' which is 1 and second, I am trying to make the scale of x axis from -inf to inf but that is not working.
I am actually trying to make the x axis ticks as [ -inf -15 -10 -5 0 5 10 15 int] but i am still trying to figure out how to do that.
Can someone help me with this. Any help is appreciated.
Thank you

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 1월 13일
Note that [inf -inf] will make your plot hardly visible and thus, you had better take a bit larger values to the two extreme points, e.g.:
x = [1 0.93 1 0.96 1 1 1 0.86];
snr = [Inf 9 -0.539 -4.98 -7.9 -10.08 -11.83 -13.28];
plot(snr,x, 'ro-', 'linewidth', 2), grid on
ylim([0 1])
xlim([-25 25])
xticks([-25 -15 -10 -5 0 5 10 15 25])
xticklabels({'-inf', '-15', '-10', '-5', '0', '5', '10', '15', 'inf'})
  댓글 수: 2
Raghav Rathi
Raghav Rathi 2023년 1월 13일
That was really helpful thanks a lot. But why is the value corresponding to 'inf' which is '1' not being plotted?
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 1월 13일
Here is how you can make it visible:
x = [1 0.93 1 0.96 1 1 1 0.86];
snr = [-25 9 -0.539 -4.98 -7.9 -10.08 -11.83 -13.28];
[SNR, IND] = sort(snr);
X = x(IND);
plot(SNR,X, 'ro-', 'linewidth', 2), grid on
ylim([0 1])
xlim([-25 25])
xticks([-25 -15 -10 -5 0 5 10 15 25])
xticklabels({'-inf', '-15', '-10', '-5', '0', '5', '10', '15', 'inf'})

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by