Different colors in Histogram (MATLAB)

4 ビュー (過去 30 日間)
high speed
high speed 2022 年 6 月 23 日
回答済み: KSSV 2022 年 6 月 23 日
Dear;
I have created this simple program to plot the histogram of these values:
Iter=[30 55 64 130 186 432];
SNR=[9 8 8 9.3 6 6.7];
stem (Iter,SNR,'linewidth',2);
axis([0 450 0 10]);
xlabel('Number of iterations');
ylabel('SNR(dB)');
Can you help me to change the color of each bar please.
Also I want to place a text atop each bar. How can I do that ?

採用された回答

KSSV
KSSV 2022 年 6 月 23 日
Iter=[30 55 64 130 186 432];
SNR=[9 8 8 9.3 6 6.7];
color = {'r','b','g','y','m','k'} ;
figure
hold on
for i = 1:length(Iter)
stem (Iter(i),SNR(i),'linewidth',2,'color',color{i});
end
axis([0 450 0 10]);
xlabel('Number of iterations');
ylabel('SNR(dB)');

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by