Unable to set the scale fro -inf to inf
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
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 Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!