plot limit problem for x sides

2 ビュー (過去 30 日間)
amani
amani 2024 年 9 月 7 日
回答済み: nick 2024 年 9 月 12 日
the code show to me my plot just for x=12 i need it to work for x=0
i did the xlim and the ylim but i havn't no think !
semilogy(vec_SNR_dB,var_ber, 'c', 'MarkerSize', 3 );
ylim( [ 1e-6, 100 ] ); xlim( [ 0, 20 ] );
grid on;
hold on ;
can some one help me plz !
  2 件のコメント
Torsten
Torsten 2024 年 9 月 7 日
編集済み: Torsten 2024 年 9 月 7 日
Maybe the first row or column of "vec_SNR_dB" starts with 0 and the second with 12. Or some elements are NaN so that they are not plotted. We can't tell without the data for "vec_SNR_dB" and "var_ber".
Tomasz
Tomasz 2024 年 9 月 9 日
編集済み: Tomasz 2024 年 9 月 9 日
In the code you have
mod_order = 16;
vec_EbN0_dB = 0:2:20
vec_EbN0_dB = 1x11
0 2 4 6 8 10 12 14 16 18 20
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
vec_SNR_dB = vec_EbN0_dB + 10*log10(mod_order)
vec_SNR_dB = 1x11
12.0412 14.0412 16.0412 18.0412 20.0412 22.0412 24.0412 26.0412 28.0412 30.0412 32.0412
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
your problem is that you create the X vector for your plot using summation, and the second part of that sum is constant 12.0412 so your X vector will always start with an offset.
You must design vec_SNR_dB in a way that is tarts at 0.
Why not just use vec_EbN0_db? It starts at 0 and end at 20. And If you need somevery specific points on the X axis then just create a vecotr for those values manually, or figure out different formula.

サインインしてコメントする。

回答 (1 件)

nick
nick 2024 年 9 月 12 日
Hi Amani,
It seems that the variable 'vec_SNR_dB', which represents the Signal to Noise Ratio in decibels, should be on the y-axis instead of the x-axis in the figure. The function 'semilogy' has arguments in the following order: (X,Y) where represents x- and y-coordinates respectively.
You can refer to the following documentation to learn more about the function 'semilogy':
To represent the plot accurately, you should use the 'semilogy' function as follows:
semilogy(var_ber,vec_SNR_dB, 'c', 'MarkerSize', 3 );
Kindly please share a reproducible version of the code to narrow down the other potential problems.

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by