Handle line from two vectors
1 回表示 (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (2 件)
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 件のコメント
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
2013 年 4 月 9 日
1 件のコメント
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 Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!