plot multiple points in multiple colors

1 回表示 (過去 30 日間)
ankita
ankita 2014 年 3 月 5 日
回答済み: Iswarya 2025 年 1 月 7 日
I am trying to plot the peaks and their harmonics. Figure 5 plots the peaks between 0-135 Hz and figure 6 plots the peaks and their harmonics between the normal frequency range i.e. 0-2000 Hz.
The first part of Figure 6 plots normal graph between freq_s(0-2000 Hz) and Signal_fft_hilbert. I want to plot xx2 peaks on this plot. I am not able to draw this plot. I want to mark these points in different colors for each 'k'.Also I am getting error with regards to size of freq_s and xx2. Can somebody suggest anything?
figure(5)
ind = (freq_s>=0 & freq_s<= 135); %// logical index to select desired range
[peaks, locs] = findpeaks(abs(Signal_fft_hilbert(ind)))
plot(freq_s(locs),abs(Signal_fft_hilbert(locs)))
hold on
plot(freq_s(locs),peaks,'*g')
for k=1:length(peaks)
z=z+1;
top1{k}=freq_s(locs(k));
for s1=1:length(peaks)
xx{s1}=top1{k}*s1;
end
[xx1]=[xx(:)]
xx2=cell2mat(xx1);
figure(6)
plot(freq_s(2:250),abs(Signal_fft_hilbert(2:250)))
hold on
plot(freq_s,xx2,'*g')
end
  4 件のコメント
Patrik Ek
Patrik Ek 2014 年 3 月 5 日
You must have two vectors of the same size when using plot. Try to filter the point you need from each vector and make sure to have the same size of them.
Muhammad Imran
Muhammad Imran 2014 年 3 月 5 日
If the data is of differrent in dependenta variable and you wish to plot in same figure you can use command (plotyy)

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

回答 (2 件)

Paul
Paul 2014 年 3 月 5 日
編集済み: Paul 2014 年 3 月 5 日
col=1:numel(peaks);
scatter(freq_s(locs),peaks,[],col)
You can specify the size of the circles where [] is. Im not sure what xx2 is supposed to be. But if you want to plot that replace peaks with xx2.

Iswarya
Iswarya 2025 年 1 月 7 日
how to get color for different signals

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by