Handle line from two vectors

2 次查看(过去 30 天)
Raúl
Raúl 2013-4-9
Hi all,
I'm generating a plot from two vectors. These vectors are shown below. I would like to save this generated line in a variable but I don't know how to do it. Using h = plot ()? or maybe h=line ( )?
x = [0.321068845472351 0.390576047611591 0.458077695482386 0.523303046872897 0.586026145644356 0.646068077345132 0.703297510311817 0.757629581578299]
y = [0.440000000000000 0.540000000000000 0.640000000000000 0.740000000000000 0.840000000000000 0.940000000000000 1.040000000000000 1.140000000000000]
Also, I want to use this line to get the intersection with other line create with the command line.
Can I use the function interp1? How?
Thanks a lot.
Raúl.

回答(2 个)

Jan
Jan 2013-4-9
h = plot() and h=line() are both valid solutions. So why not simply try it?
For finding the points of intersections, an interpolation is not helpful. But you can guess that other programmers have worked on this problem also, such that it is a good idea to ask your favorite internet search engine about "Matlab intersection of lines" before you ask the forum. I really appreciate the knowhow of the forum, but Google finds 783'000 results in 0.43 seconds, and this is nothing we can compete with.
  2 个评论
Raúl
Raúl 2013-4-9
I've tried both options. Always, I mean always I try to get it by myself and searching through google before asking questions to the forum. I've spent many hours trying to fix it.
Jan
Jan 2013-4-9
编辑:Jan 2013-4-9
@Raul: Flagging is thought to inform the admins and editors about an answer, which conflicts with the forum rules. "Inappropriate answer" means, that it contains rudeness, spam or has an offending contents. Then the editors or the admins delete the message and give the user a warning.
Are you really sure that you want to flag my answer? If so, I let other editors react to this.
Please do not write only, that you have tried both, but post the code and show us the error messages or explain the differents between the results and your expectations. The message you have posted in the answers section, sounds, like you have wrong expectations about the output of the plot and line commands. Then reading the documentation is helpful. It is not clear, what it exactly mean to "save this generated line in a variable".
I do not know, why you've spent hours with this problem. Under the first hits found by Google there are working solutions already. Therefore I suggest, that you show us the code you have tried to solve the problem with.

请先登录,再进行评论。


Raúl
Raúl 2013-4-9
I would like to add that the value from 'h' using both options is a double instead of a vector of doubles as it should be.
Thanks.
  1 个评论
Jan
Jan 2013-4-9
No, Raul, the replied "h" is the handle of the line, which is a kind of pointer or address. It can be used to modify the properties of the created object. It is not expected to contain the X- and Y-Data of the created line. Therefore the commands are working properly and exactly as explained in the documentation. But your expectations are wrong.
Please do not post comments in the asnwer section. Insert all useful information in the original question, because readers expect them there.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by