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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Plotting a Grid or a Structure on a Graph

wayne
12-Amethyst

Plotting a Grid or a Structure on a Graph

Attached is what I am settling on as the best way to create a grid or to plot a structure on a graph,

Any suggestions?

Thanks,

Wayne

ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:wayne)

I think you are making it somewhat more complicated than it needs to be, You don't need all those NaNs.

View solution in original post

23 REPLIES 23
VladimirN
24-Ruby II
(To:wayne)

Wayne,

Thank you for this program!

Wayne Reid wrote:

Any suggestions?

Thanks,

Wayne

It is a subroutine?!

A subroutine must not be depended on an ORIGIN value!

I think so!

Wayne,

I have a new idea, but it's still a working progress

I am planning on using my Lines function.

Mike

RichardJ
19-Tanzanite
(To:wayne)

I think you are making it somewhat more complicated than it needs to be, You don't need all those NaNs.

wayne
12-Amethyst
(To:RichardJ)

Richard,
Thanks, that is much cleaner

Needed all then NaN's because the the results were not always the same without being redundant. I assume that I will not have the same problems with what you sent.

Generally, plotting A to B to NaN works for a simple gird, but not always for other structures. (that's why I said "assume" above)

Plotting A to B to A to NaN seems to always work, but it's sort of vulgar.

Again,

Thanks

RichardJ
19-Tanzanite
(To:wayne)

Yes, this will always work.

Perhaps a more detailed explanation (i.e. more detailed than no explanation at all ) will help clarify.

Take a polyline with N segments, so N+1 x coordinates and N+1 y coordinates. This can be plotted as an N+1 vector of the x coordinates vs an N+1 vector of y coordinates (obviously!). If we have multiple polylines then we can create a matrix of x coordinates and a matrix of y coordinates. Each column will be plotted as an independent polyline. If we like (and I do, so I always do it this way) we can combine the x and y coordinates into one matrix by using complex numbers of the form x+iy, and then create the x and y matrices on the fly when plotting by using the Re and Im functions. For a grid the lines only have one segment, so the matrix only has two rows. If we have lines with different numbers of segments then the unused positions in the matrix can be filled with NaNs: see the slightly modified worksheet.

Example of Plotting a Grid.

Vyacheslav.

Nicely done.

Worksheet would be more useful though.

Mike

Mike Armstrong wrote:

Nicely done.

Thanks Mike.

Mike Armstrong wrote:

Worksheet would be more useful though.

Mike

I made ​​it for more than five years ago (see the forum http://forum.exponenta.ru/viewtopic.php?p=13690 - my username BAT). I need to find a sheet in its archives. There I used the idea, the secret is not opened until now. I'll post later of the idea of a simple example.

Vyacheslav.

Superb work, cheers.

Mike

Mike Armstrong wrote:

Superb work, cheers.

Mike

Thanks Mike.

The essence of the trick is simple. However, despite its simplicity, its application is very efficient. Below this is shown by simple examples.

It's time to reveal secrets.

Mesh_Plot_VyaT.PNG

Vyacheslav.

Another neat trick, very nice.

Mike

Mike Armstrong wrote:

Another neat trick, very nice.

Mike

Thanks Mike.

Search the worksheet with "Cheshire cat smile" was successful.

Vyacheslav.

Superb Richard, exactly what I was planning to achieve. Don't have to bother now

Mike

AlanStevens
17-Peridot
(To:wayne)

Here's how I'd do it.

Alan

wayne
12-Amethyst
(To:AlanStevens)

Thanks Alan,

That's clever.

I mentioned grids because I thought that would get the most interest.

However, I am actually looking for the best method to plot a structure that, in general, does not correspond to a grid.

By the way, I think you are guilty of suggesting that I use NaN's last September or so (Richard was supposedly at a "convention" at the time)

Thanks,

Wayne

AlanStevens
17-Peridot
(To:wayne)

Wayne Reid wrote:

Thanks Alan,

That's clever.

I mentioned grids because I thought that would get the most interest.

However, I am actually looking for the best method to plot a structure that, in general, does not correspond to a grid.

Oh well, another good idea bites the dust!

By the way, I think you are guilty of suggesting that I use NaN's last September or so (Richard was supposedly at a "convention" at the time)

Thanks,

Wayne

Yep, that would be me - nothing wrong with a few good NaNs! (Are you intimating that Richard might be something other than an honest, trustworthy, solid citizen?)

Alan

This is how I do it, Wayne.

Bill Wadsworth

Thanks, Bill

I am in trouble again, so I will look at later, nice work though.

Bill

That is a nice worksheet.

But what I am looking for is to plot an entire structure from one matrix, not using a different matrix for each type or group or continuous line. The problem I have does not show up in your plots.

See the next response to Richard, still have problem.

Thanks,Wayne

Richard,
Unless I am messing something up (not at all unlikely), even using the Re and Im method, I still must plot A to B to A to NaN to get all the lines all the time.

I like the method though, it's more concise, but in the end it is really the same, just need extend.

I look forward to your response.

Thanks, Wayne

RichardJ
19-Tanzanite
(To:wayne)

Well, that is interesting. The person that missed something is me. It's a bug. It works fine in MC11 and MC13, but not in MC15 (and I assume not in MC14). I am amazed I have not noticed before that this bug exists.

If you take your final matrix and remove the last row (all the NaNs) you will notice that it still works. The NaNs really aren't necessary. Now remove the first row. It still works . Why? Because the direction of the lines has been reversed so that the start of the second line is not at the end of the first one. It seems that if the start of one line is at the same coordinates as the end of the previous line, then that line is not plotted. You can also make the second line show up by changing 5i to 5.1i. When I drew the triangle earlier in the worksheet I got lucky, because I happened to define the lines so that they were reversed. That was not by design.

The good news is that there is a very easty fix that does not require any changes to the math in the worksheet. In the format options, change the type from "lines" to "draw".

wayne
12-Amethyst
(To:RichardJ)

Thanks Richard

You have restored my faith.

FYI, it is this way in 14 also; I have been doing it this way for a while.

It must have occured in some other versions also, because in the Ebook for FEM, he plotted using a vary large number in place of the NaN's (which was an even worse solution)

Announcements

Top Tags