Hi eveybody
I could not fill the gap betwween 2 curves. it is shown in below figure.
can anyone help me?
thanks
The code I used is:
plot(KI1,KP1);
xlabel('K_I');
ylabel('K_P');
grid on
hold on
x2=zeros(1,150)
y=linspace(-20,40,numel(x2))
plot(x2,y,'linewidth',2)

댓글 수: 6

darova
darova 2020년 4월 10일
Did you try area? What about intersection fo curves?
halil hasan
halil hasan 2020년 4월 12일
I tried, but may be wrong parameter selection I couldnt succeded.
darova
darova 2020년 4월 12일
Maybe i can correct your code? Allow me to help you
halil hasan
halil hasan 2020년 4월 12일
thanks drova
I have given the code above.
darova
darova 2020년 4월 12일
I have an error here
Do you know why?
halil hasan
halil hasan 2020년 4월 13일
KI1 and KP1 are vectors. they can have any value.

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

 채택된 답변

Les Beckham
Les Beckham 2020년 4월 11일

0 개 추천

What do you mean by "fill the gap"? Do you want to connect the start and end points so that this becomes a closed curve? If so, this should do it:
plot([KI1(:); KI1(1)], [KP1(:); KP1(1)]);
xlabel('K_I');
ylabel('K_P');
grid on

댓글 수: 7

halil hasan
halil hasan 2020년 4월 12일
Thanks alot for replay Beckham
This is 2 different curve. I wanna fill intersection of them(closed area) with a color.
Les Beckham
Les Beckham 2020년 4월 12일
편집: Les Beckham 2020년 4월 12일
In that case, try something like this (I've made up some data that is somewhat similar to your plot, though not as smooth).
KI1 = [0 -190 -100 0 90 80];
KP1 = [40 5 -18 -16 -5 -2];
fill([KI1(:); KI1(1)], [KP1(:); KP1(1)], 'b', 'EdgeColor', 'None') % Fill the shape with blue
hold on
plot([KI1(:); KI1(1)], [KP1(:); KP1(1)], 'k', 'LineWidth', 2) % Outline the edges in black
xlabel('KI1')
ylabel('KP1')
If this doesn't get you to what you want, it would help if you share the data for KI1 and KP1.
halil hasan
halil hasan 2020년 4월 13일
Thanks alot Beckham
but I want to fill KI1<0 part, not all of them
halil hasan
halil hasan 2020년 4월 13일
how to fill just left of KI=0 line in your figure?
Maybe this will do what you want:
KI1 = [0 -190 -100 0 90 80];
KP1 = [40 5 -18 -16 -5 -2];
idx = find(KI1 <= 0); % find indices of non-positive KI1 values
fill([KI1(idx) KI1(find(idx,1))], [KP1(idx) KP1(find(idx,1))], 'b', 'EdgeColor', 'None')
hold on
plot([KI1(:); KI1(1)], [KP1(:); KP1(1)], 'k', 'LineWidth', 2)
xlabel('KI1')
ylabel('KP1')
halil hasan
halil hasan 2020년 4월 14일
Thanks alot for your kind replies, Beckham
Les Beckham
Les Beckham 2020년 4월 14일
You are welcome. Glad I could help.

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

추가 답변 (1개)

darova
darova 2020년 4월 13일

0 개 추천

Here is my shot
y = 0:0.1:pi;
x1 = -sin(y);
x2 = y*0-0.3;
[xc,yc] = polyxpoly(x1,y,x2,y);
xx = [xc(1) x1(x1<x2) xc(end)];
yy = [yc(1) y(x1<x2) yc(end)];
plot(x1,y,x2,y)
patch(xx,yy,'r')
line(xc,yc,'marker','o')
success?

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2020년 4월 10일

댓글:

2020년 4월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by