How to use xline?

110 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 7 月 18 日
コメント済み: Tomasz Cudejko 2022 年 7 月 18 日
Hi all,
I have a signal (attached) over which I would like to plot mutiple vertical lines using x values (see image below)
x = [1648;2871;4022;6216;7327;8416]
My approach below:
can you help please?
load 'signal'
figure;
plot(cop_x_l); hold on
xline([x], repmat(ylim',1,size(x,2)), '--r')
Error using xline (line 29)
Passing multiple values to ConstantLine is not supported.

採用された回答

Steven Lord
Steven Lord 2022 年 7 月 18 日
The ability to create multiple vertical or horizontal lines by passing a vector of values into the xline or yline functions was introduced in release R2021a. For earlier releases you'll need to call xline or yline once per value (perhaps in a for loop.)
  1 件のコメント
Tomasz Cudejko
Tomasz Cudejko 2022 年 7 月 18 日
@Steven Lord Thanks Steven, that explain my issues

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

その他の回答 (2 件)

vishweshwar samba
vishweshwar samba 2022 年 7 月 18 日
Try this
x = [1,2,3,4,5]; % x interval
% load signal instead of data below
z = linspace(0,6,100);
y = exp(z);
plot(z,y);
xline(x,'-r');

Abderrahim. B
Abderrahim. B 2022 年 7 月 18 日
編集済み: Abderrahim. B 2022 年 7 月 18 日
Hi!
Try this
sig = rand(1,10000) ;
x = [1648 2871 4022 6216 7327 8416] ;
figure
plot(sig);
hold on
xline(x, '--r')
Hope this helps

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by