how can I join points along a two plots with straight lines?

2 ビュー (過去 30 日間)
Brendan Atarigiya
Brendan Atarigiya 2016 年 7 月 8 日
コメント済み: Brendan Atarigiya 2016 年 7 月 8 日
hello. I have written this code to draw a slope model for me. First, there is the linear slip surface and then the circular slip surface. both functions have thesame vectorizations. Now I want to connect the points of both plots with straight lines. Can anyone help me out??? thank you"
H = 5;
Xc =7;
Yc = 11;
R = 20;
fr = 45; % slope angle in degrees
tfr = tand(fr); % slope angle in gradient
%%Slip surface generation
xmin = Xc - sqrt(abs(R^2 - Yc^2)); % Exit point of slip circle
xmax = Xc + sqrt(abs(R^2 - (Yc-H)^2)); % Entry point of slip circle
x = linspace(xmin,xmax,ns)'; % Positions where the forces will be analyzed.
ybot = Yc - sqrt(abs(R^2-(x-Xc).^2)); % Equation for generating slip circle
%%Slope surface generation
ytop = (x>=0).*(x<(H/tfr)).*(x*tfr) + (x>=(H/tfr)).*H; % Slope surface. equation of a line is used
figure(1);
plot(x,ybot,'-r',x,ytop,'-r')

採用された回答

Jan Orwat
Jan Orwat 2016 年 7 月 8 日
add at the end something like that:
hold on
plot(reshape([x,x,x].',1,[]),reshape([ytop,ybot,ytop*NaN].',1,[]))
  2 件のコメント
Jan Orwat
Jan Orwat 2016 年 7 月 8 日
In general, you can combine vectors (say A and B) in manner like
[A(1) B(1) NaN A(2) B(2) NaN ...]
but not manually, via concatenation and reshaping.
Note, that without including NaNs you will get saw-like shape.
Brendan Atarigiya
Brendan Atarigiya 2016 年 7 月 8 日
Thank you very much Jan, you are a life saver.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by