How to plot mutiple vertical lines over x axis ?

3 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 7 月 15 日
コメント済み: Tomaszzz 2022 年 7 月 15 日
Hi all,
I would like to plot multiple vertical lines in force_y_r as specified by x1 and x 2
force_y_r is 9607x1 double matrix (attached)
x1 = [1649;2883;4029;5097;6230;7324;8432;9518];
x2 = [2482;3628;4706;5852;6946;8036;9149]
The below gives me an error. Could you please help?
load 'signal'
plot(force_y_r); hold on
plot([x1; x1], repmat(ylim',1,size(x1,2)), '--r')
plot([x2; x2], repmat(ylim',1,size(x2,2)), '--r')
hold off
Error using plot
Vectors must be the same length.

回答 (1 件)

Simon Chan
Simon Chan 2022 年 7 月 15 日
User function xline is easier.
  1 件のコメント
Tomaszzz
Tomaszzz 2022 年 7 月 15 日
@Simon Chan Many thanks. Still dont get it right.
plot(force_y_r,); hold on; xline([x1 x2],'--')
Error using xline (line 29)
Passing multiple values to ConstantLine is not supported.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by