How to plot a dispersion diagram like this?

조회 수: 17 (최근 30일)
Amir Farrokhnejad
Amir Farrokhnejad 2020년 11월 3일
댓글: Amir Farrokhnejad 2020년 11월 5일
hello everyone,
I need to plot such a diagram in matlab but I don't know how exactly I can do this. may you please help me to know how I would be able to plot a dispersion diagram like this one below?
  댓글 수: 2
dpb
dpb 2020년 11월 3일
Just plot each line in succession after hold on
If you have all the data at once, put into 2D array by column for each variable and each will be plotted in one call to plot()
Include the discontinuous pieces to draw on top of the axes; will have to have the limits consistent to draw on the axis itself.
Amir Farrokhnejad
Amir Farrokhnejad 2020년 11월 5일
Thanks for your response
but in this case my problem is that I don't know how exactly I can code such a plot

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

채택된 답변

Swetha Polemoni
Swetha Polemoni 2020년 11월 5일
Hi
It is my undersatanding that you want to draw ellipse, hyperbola and straight line in first quadrant. Try the following code and experiment with alpha, beta and f to get the exact diagram as you need.
%% plotting ellipse
alpha=20;
theta=0:0.01:pi/2;
x1=alpha*cos(theta);
y1=sin(theta);
axis([0 20 0 1])
plot(x1,y1);
hold on
%% plotting hyperbola
beta=15;
fun1 = @(x2,y2) y2.^2 - (x2/beta).^2 -1;
fimplicit(fun1,[0 20 0 2]);
hold on
%% plottig straight line
f=0.09;
x3=0:0.1:17;
y3=f*x3;
plot(x3,y3)
hold off
  댓글 수: 1
Amir Farrokhnejad
Amir Farrokhnejad 2020년 11월 5일
Hello Swetha
Thanks for your response. It solved my problem!
All the best

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-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