フィルターのクリア

how to plot impulses obtaining x and y values (non periodic) from 2 separate matrices

3 ビュー (過去 30 日間)
I want to be able to plot x and y data stored in two separate matrices as an impulse graph similar to the image below but not periodic. I know the stem function is used to generate these types of graphs but the difference here is that my data is aperiodic. Any feedback would be much appreciated. Thank you.
  2 件のコメント
Paul
Paul 2021 年 11 月 12 日
It would be helpful to post input data for the simplest possible example that illustrates the problem and explain how that data should be turned into the desired output.
Ruben Leon
Ruben Leon 2021 年 11 月 12 日
Sure. These are two (2x3) matrices containg the typy of data I would like to plot.
SpurOffsetFreq = [37.467 56.486 85.159; 56.486 86.693 113.309];
SpurLeveldBc = [-96.527 -97.912 -83.814; -100.779 -84.146 -92.496];
but instead of ploting it using the regular plot function (shown below) which connects each data point (image below) I want to plot an impulse/vector located at each x value going up to its corresponding y value. A noise floor would have to be set lets say at y=-110dBc and so there would be a vector going from -110 to -96.527(y) located at 37.467(x) and so on for all the data points.
figure
hold on
for i = 1:N
plot(SpurOffsetFreq(i,:),SpurLeveldBc(i,:))
end
xlabel('Spur Offset Frequency (KHz)')
ylabel('Spur Level (dBc)')

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

採用された回答

Paul
Paul 2021 年 11 月 13 日
Is one of these what you want?
SpurOffsetFreq = [37.467 56.486 85.159; 56.486 86.693 113.309];
SpurLeveldBc = [-96.527 -97.912 -83.814; -100.779 -84.146 -92.496];
% two separate stem plots
figure;
hold on;
for ii = 1:2
stem(SpurOffsetFreq(ii,:),SpurLeveldBc(ii,:),'BaseValue',-110);
end
% single stem plot
figure
stem(SpurOffsetFreq(:),SpurLeveldBc(:),'BaseValue',-110)
  1 件のコメント
Ruben Leon
Ruben Leon 2021 年 11 月 15 日
編集済み: Ruben Leon 2021 年 11 月 15 日
Hi Paul, yes, thats exactly what I need. Thank you! I thought Periodicity was a requirement for using the stem function but I was clearly wrong.

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

その他の回答 (1 件)

Dave B
Dave B 2021 年 11 月 13 日
I think you were correct that stem is the correct command. I'm not sure why periodicity factors in, from your description...how about this?
SpurOffsetFreq = [37.467 56.486 85.159; 56.486 86.693 113.309];
SpurLeveldBc = [-96.527 -97.912 -83.814; -100.779 -84.146 -92.496];
% the loop is not necessary when your data are in a matrix
stem(SpurOffsetFreq,SpurLeveldBc,'filled','BaseValue',-110)
xlabel('Spur Offset Frequency (KHz)')
ylabel('Spur Level (dBc)')

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by