cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

graphing non connected line segments, using matrices

wayne
3-Visitor

graphing non connected line segments, using matrices

I want to be able to graph a variable number of line segments, which may or may not be connected.

Say: P1 to P2, P3 to P4, P1 to P4, etc.

Can easily do by just plotting x-y corrdinate pairs for each end (x1 x2) and (y1 y2), but then I must include each set in the graph individually.

Plese see the attached; it seems that to be assured of getting the desired result I must do the following:

Each row of the X and Y matrices contains the corrdinates of each end of the segment, but I must add to that as follows:

each row of X ( xP1 - xP2 - xP1 - xLarge), Y (yP1 - yP2 - yP1 - yLarge)

and then in addition I must add a reference to a non-existant point. (j=0 to 5, instead of 4)

This is the only way I ave been able to "pick up and move the pen" to another piont.

I am almost embarrased to post that because it makes no sense, but maybe it does?

Is there a coherent explaniation for this? Is there a better way?

Thanks,

Wayne

1 ACCEPTED SOLUTION

Accepted Solutions
AlanStevens
17-Peridot
(To:wayne)

Add a row of NaNs between each line.

Alan

View solution in original post

9 REPLIES 9
wayne
3-Visitor
(To:wayne)

Attached fiel in version 11

MikeArmstrong
5-Regular Member
(To:wayne)

I am almost embarrased to post that because it makes no sense, but maybe it does?

Why would you be embarrassed to post a question? The reason you haven't had response is because it is a sparsely covered area.

I'm not sure exactly what you want, but I have had a go.

Mike

Mike, thanks for taking a stab at it.

a need a more automated solution, I may have 2 segments (structural elements) or I may have 10, 20, 30, maybe more down the road. I do not want to list each point individually.

The example at the end correctly reflects the structure. I have two questions:

1) The method works, but I cannot explain why, its sort of nonsensical, any logical explaination?

2) Is there a better method?

I don't really see anthing in help or the referenced, except in "Finite Element Beginnings", ans I had to take that another step to get what I needed.

I could potentially use this extensively, and I am sure there are many other have done, or would use If they knew.

Thanks,

Wayne

AlanStevens
17-Peridot
(To:wayne)

Add a row of NaNs between each line.

Alan

MikeArmstrong
5-Regular Member
(To:AlanStevens)

Very nice trick.

Didn't think of trying that.

Mike

Alan,

Thanks, much simpler.

In my case, adding column to each; every line is an individule line.

But, to get consistent results, I need to do the following:

draw line from point i to point j, then back to point i, then to NaN point.

(much better the point i to point j, then back to point i, then to distant point, then to non-existand column)

I can live with the solution and it is easy to implement.

Thanks agian

Wayne

PhilipOakley
5-Regular Member
(To:wayne)

Look at the "Amazing Images" handbook (on the resource centre if you can find it) This has lots of cases of plotting multiple segments.

You can also plot matrices as sets of lines (needs a common x axis I think).

There was a difference between "draw" and "line" plots in older versions which stopped the flyback line being drawn. In recent versions I think you either needed the NaN or complex trick (complex values are not drawn) to eliminate the line segments that joined at the ends of teh flyback.

Also if the end point (x-value) was off the graph space then it didn't draw that bit of the line in some cases. The exact rules vary and aren't always fully discovered 😉 [i.e. it is actually following a completely different rule to get to the same result in a particular case]

Philip

Phillip,

I will seek out the reference.

See Alan's comment for an acceptable solution; (essentailly the same as what you were saying ) but I will see if even a better one in the reference.

Thanks for the insite as well

Wayne

MikeArmstrong
5-Regular Member
(To:wayne)
Top Tags