Using matlab to find points on different curves and then join them up

Basically I have created a file which produces a graph with a number of lines on, but need to produce a curve on top. For example, the picture 2nd from bottom on this site shows what im aiming for:
https://www.e-education.psu.edu/png520/m3_p3.html
I have the lines but need to produce the dotted line.
I know the y cooridinates of where the dotted line crosses each other lines, but need to use matlab to find the x coordinates, to plot markers onto the graph and to then join them up with a line.
I've been trying things for ages but am fairly new to matlab.
Would appreciate some help, thankyou!

답변 (2개)

Paulo Silva
Paulo Silva 2011년 1월 23일
%This is how you make a line interactively using left mouse button
%you can see the coordinates of the points on the matlab command line
clf %clear a figure, comment this to plot on a existing figure
clear %clears the variables
axis([0 1 0 1]) %define you axis max and min values [xmin xmax ymin ymax]
hold on %add stuff to the axis without clearing what's there before
for n = 1:2 %choose two points
[x(n),y(n)] = ginput(1) %waits for you to click on a point on the graph
plot(x(n),y(n),'x') %mark a cross in the point you choose
s=sprintf('Point %d',n); %make the "name" of the point
text(x(n),y(n),s) %insert text Point 1 and after the Point 2
end
line(x,y,'LineStyle','--') %creates a line between two points
%line with diferent atributes from the defaults
%line(x,y,'LineStyle','--',...
%'LineWidth',4,...
%'Color','r') %creates a line between two points
Jay
Jay 2011년 1월 23일

0 개 추천

Thankyou. I'll try it in the morning and let you know how it goes! I'm not sure how accurate it will be but i'll try!

댓글 수: 1

That's just a demo with functions you will need, try them and adjust the code to your needs.
Any doubt about a function just write doc followed by the name of the function in matlab command line, for example
doc line

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

카테고리

도움말 센터File Exchange에서 Desktop에 대해 자세히 알아보기

제품

질문:

Jay
2011년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by