MATLAB Answers

how to compare two graphs having different values on x-axis?

37 ビュー (過去 30 日間)
Sajid Sarwar
Sajid Sarwar 2019 年 4 月 25 日
コメント済み: Mark Sherstan 2019 年 4 月 27 日
I have two sets like
SINRo=[3.16455696202532 4.74683544303798 6.32911392405063 7.91139240506329 9.49367088607595 11.0759493670886 12.6582278481013 14.2405063291139 15.8227848101266 17.4050632911392 18.9873417721519 20.5696202531646 22.1518987341772 23.7341772151899 25.3164556962025 26.8987341772152 28.4810126582278 30.0632911392405 31.6455696202532]
BERo=[0.00593858219443245 0.00103090943726315 0.000186958235751604 3.47799042686922e-05 6.57942637416831e-06 1.25953352221493e-06 2.43270098650139e-07 4.73109453014439e-08 9.25181229640331e-09 1.81738969741591e-09 3.58342922495624e-10 7.08807422645925e-11 1.40585132440117e-11 2.79495469346670e-12 5.56809307580009e-13 1.11129464517693e-13 2.22154555075486e-14 4.44744502578834e-15 8.91522895859371e-16]
semilogy(SINRo, BERo, 'green')
and 2nd set
SINR=[1.68286918010400 1.70143046563433 1.72214758561361 1.74541956953215 1.77175048324529 1.80178645839125 1.83636959314033 1.87661844127445 1.92405178613187 1.98078558250780 2.04985916339183 2.13580215490112 2.24567920343178 2.39116168757851 2.59304429421746 2.89243885339408 3.38419129859504 4.35229343567443 7.35760686444023]
BER=[0.0430299901671800 0.0426953195435822 0.0423234293968646 0.0419077600255308 0.0414401186567641 0.0409101394647823 0.0403045152395113 0.0396058802708295 0.0387911461989609 0.0378289540298949 0.0366756497062147 0.0352686994150433 0.0335154784077252 0.0312733285662269 0.0283124876629703 0.0242452307540428 0.0184002036036845 0.00979380677850566 0.000484978579323264]
semilogy(SINR, BER, 'green')
i want to compare their results, i mean they should be on same window like a file i hav attached

回答 (1 件)

Mark Sherstan
Mark Sherstan 2019 年 4 月 25 日
Add a "hold on" statment which basically will make the two plots combined. I have modified your code below:
clear all
close all
SINRo=[3.16455696202532 4.74683544303798 6.32911392405063 7.91139240506329 9.49367088607595 11.0759493670886 12.6582278481013 14.2405063291139 15.8227848101266 17.4050632911392 18.9873417721519 20.5696202531646 22.1518987341772 23.7341772151899 25.3164556962025 26.8987341772152 28.4810126582278 30.0632911392405 31.6455696202532]
BERo=[0.00593858219443245 0.00103090943726315 0.000186958235751604 3.47799042686922e-05 6.57942637416831e-06 1.25953352221493e-06 2.43270098650139e-07 4.73109453014439e-08 9.25181229640331e-09 1.81738969741591e-09 3.58342922495624e-10 7.08807422645925e-11 1.40585132440117e-11 2.79495469346670e-12 5.56809307580009e-13 1.11129464517693e-13 2.22154555075486e-14 4.44744502578834e-15 8.91522895859371e-16]
SINR=[1.68286918010400 1.70143046563433 1.72214758561361 1.74541956953215 1.77175048324529 1.80178645839125 1.83636959314033 1.87661844127445 1.92405178613187 1.98078558250780 2.04985916339183 2.13580215490112 2.24567920343178 2.39116168757851 2.59304429421746 2.89243885339408 3.38419129859504 4.35229343567443 7.35760686444023]
BER=[0.0430299901671800 0.0426953195435822 0.0423234293968646 0.0419077600255308 0.0414401186567641 0.0409101394647823 0.0403045152395113 0.0396058802708295 0.0387911461989609 0.0378289540298949 0.0366756497062147 0.0352686994150433 0.0335154784077252 0.0312733285662269 0.0283124876629703 0.0242452307540428 0.0184002036036845 0.00979380677850566 0.000484978579323264]
figure(1)
hold on
semilogy(SINRo, BERo, 'green')
semilogy(SINR, BER, 'green')
hold off
  2 件のコメント
Mark Sherstan
Mark Sherstan 2019 年 4 月 27 日
Look at the axes function (https://www.mathworks.com/help/matlab/ref/axes.html) I put together a quick example below with your data. You could also try normalizing your data or resampling it to make it line up. All depends on what your analysis requires.
clear all
close all
SINRo=[3.16455696202532 4.74683544303798 6.32911392405063 7.91139240506329 9.49367088607595 11.0759493670886 12.6582278481013 14.2405063291139 15.8227848101266 17.4050632911392 18.9873417721519 20.5696202531646 22.1518987341772 23.7341772151899 25.3164556962025 26.8987341772152 28.4810126582278 30.0632911392405 31.6455696202532];
BERo=[0.00593858219443245 0.00103090943726315 0.000186958235751604 3.47799042686922e-05 6.57942637416831e-06 1.25953352221493e-06 2.43270098650139e-07 4.73109453014439e-08 9.25181229640331e-09 1.81738969741591e-09 3.58342922495624e-10 7.08807422645925e-11 1.40585132440117e-11 2.79495469346670e-12 5.56809307580009e-13 1.11129464517693e-13 2.22154555075486e-14 4.44744502578834e-15 8.91522895859371e-16];
SINR=[1.68286918010400 1.70143046563433 1.72214758561361 1.74541956953215 1.77175048324529 1.80178645839125 1.83636959314033 1.87661844127445 1.92405178613187 1.98078558250780 2.04985916339183 2.13580215490112 2.24567920343178 2.39116168757851 2.59304429421746 2.89243885339408 3.38419129859504 4.35229343567443 7.35760686444023];
BER=[0.0430299901671800 0.0426953195435822 0.0423234293968646 0.0419077600255308 0.0414401186567641 0.0409101394647823 0.0403045152395113 0.0396058802708295 0.0387911461989609 0.0378289540298949 0.0366756497062147 0.0352686994150433 0.0335154784077252 0.0312733285662269 0.0283124876629703 0.0242452307540428 0.0184002036036845 0.00979380677850566 0.000484978579323264];
figure(1)
semilogy(SINRo, BERo, 'red')
ax1 = gca;
ax1.XColor = 'r';
ax1.YColor = 'r';
ax1_pos = ax1.Position;
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
hold on
semilogy(SINR, BER, 'Parent', ax2, 'Color', 'k')
hold off
figure(2)
hold on
semilogy(SINRo, BERo, 'green')
semilogy(SINR, BER, 'red')
hold off

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

Community Treasure Hunt

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

Start Hunting!

Translated by