필터 지우기
필터 지우기

How can i plot a line from an already plotted line?

조회 수: 1 (최근 30일)
Rodrigo
Rodrigo 2023년 8월 3일
답변: Daniel Bengtson 2023년 8월 3일
I'm doing a code for brake study and, I've been trying to add a proportioning valve to my code. It essencialy creates a line in the optimum cuve graph. It is similar to this green curve:
Does anyone know how to adjust the starting point of the green line, so it starts from any poiny at the black line? Here is the method I used for this graph:
p2(32) = plot(ar_VC(find(ax_VC==ak):end),af_VC(find(ax_VC==ak):end),'-','Color', 1/255*[70,250,120],'LineWidth',3);
  댓글 수: 4
Rodrigo
Rodrigo 2023년 8월 3일
편집: Rodrigo 2023년 8월 3일
i want to translate the green line to a starting point where it stars anywhere on the black line.
And the black line was plotted like the code below, it´s a bunch of books which resulted on the black line.
p2(30) = plot(ar_4x2,af_4x2,'-','Color',1/255*[0,0,0],'LineWidth',3);
Sam Chak
Sam Chak 2023년 8월 3일
@Rodrigo, If you have a starting point (pivot) fixed on the black line, then the green line projected from the pivot, looks like rotated about the pivot relative to the black line.

댓글을 달려면 로그인하십시오.

답변 (1개)

Daniel Bengtson
Daniel Bengtson 2023년 8월 3일
% for a given value of X that lands on the defined range of the black line,
% define the corresponding Y value
X = 5;
blackX = ar_4x2;
blackY = af_4x2;
greenX = ar_VC(find(ax_VC==ak):end);
greenY = af_VC(find(ax_VC==ak):end);
% create first order fit of black line to allow for arbitrary X input
p = polyfit(blackX,blackY,1);
Y = polyval(p,X);
% shift green X and Y based on the difference between green(1) and black(1)
% then account for the translation along the black line
greenX = greenX - (greenX(1) - blackX(1)) + X;
greenY = greenY - (greenY(1) - blackY(1)) + Y;
figure;
p2(30) = plot(blackX,blackY,'-','Color',1/255*[0,0,0],'LineWidth',3);
hold on
p2(32) = plot(greenX,greenY,'-','Color', 1/255*[70,250,120],'LineWidth',3);

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by