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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

2D vector plot with nested array

NSizzle-disable
1-Newbie

2D vector plot with nested array

Hi there! first post.

I have just finished my first year at university and I am currently undertaking a student placement within an engineering firm.

I have uploaded a file (part of) so you can see what I've done to create the nested array (ysub(n) and xsub(n) concerned here) This program loop creates vectors within each cell of the nested array.

What I wish to do is plot ysub(1), ysub(n) (this goes up to ysub(63) in this case), ysub(r_up) against their respective x-correspondants.

Any help would be greatly appreciated,

Neil

p.s. also if there is a way of 'sticking' ysub(1), ysub(n), and ysub(r_up) atop each other to create one large vector, I would be very grateful if you could enlighten me!
27 REPLIES 27

Could you please add some appropriate variable definitions at the top of the worksheet so that it works, and does what you think it should do.

One immediate comment is that the default array origin in Mathcad is 0, not 1.

Richard
StuartBruff
23-Emerald II
(To:RichardJ)

On 8/7/2009 6:15:50 AM, rijackson wrote:
>Could you please add some
>appropriate variable
>definitions at the top of the
>worksheet so that it works,
>and does what you think it
>should do.

And post the revised worksheet in Mathcad 11 format as well as M14 xmcd? (You'll get a larger audience that way and most problems tend not to be too version specific)

Stuart

Hi Richard.

Sorry I can't upload the variable definitions because it's technically confidential.

And Stuart, I'm afraid I cannot upload in MathCad 11 format as my company does not have access to it. Sorry.

However, the code isn't really important. basically, I have a nested array, ysub(n). Within each 'cell' of that array there is a vector vy which can be shown on screen if I were to type ysub(value of n)=

I can, by hand, go through all these values and plot ysub(1) against xsub(1), ysub(2) against xsub(2),..., ysub(r_up=64) against xsub(r_up=64) but that would waste too much time.

My question is: Is it possible, or is there a mechanical method, on MathCad that would do this in one process i.e another program loop or some other method?

Sorry if this isn't clear.

Thanks,

Neil

Also, as a side, you can find the last index of an array by typing last(v)=, but is there a way of finding the first (I know it sounds odd as it would just be what the origin is set to but for this programmed loop of n vectors I can't just put 'zero'

I'll attach an example of the nested array size

On 8/7/2009 6:43:34 AM, NSizzle wrote:
>Hi Richard.

Sorry I can't
>upload the variable
>definitions because it's
>technically confidential.

We don't need the real data. It's hard to figure out what you are trying to do when nothing actually works though. So either you put variable definitions at the top, or we have to.

So please put in some variables with fake data.

>And
>Stuart, I'm afraid I cannot
>upload in MathCad 11 format as
>my company does not have
>access to it.

Go to "Save As" and change the format to Mathcad 11.

>Sorry.

However, the code
>isn't really important.
>basically, I have a nested
>array, ysub(n). Within each
>'cell' of that array there is
>a vector vy which can be shown
>on screen if I were to type
>ysub(value of n)=

I can, by
>hand, go through all these
>values and plot ysub(1)
>against xsub(1), ysub(2)
>against xsub(2),...,
>ysub(r_up=64) against
>xsub(r_up=64) but that would
>waste too much time.

My
>question is: Is it possible,
>or is there a mechanical
>method, on MathCad that would
>do this in one process i.e
>another program loop or some
>other method?

Yes. Change the nested vectors into columns of a matrix (so you have one x matrix and one y matrix)


Also,
>as a side, you can find the
>last index of an array by
>typing last(v)=, but is there
>a way of finding the first (I
>know it sounds odd as it would
>just be what the origin is set
>to but for this programmed
>loop of n vectors I can't just
>put 'zero'

The first element of the array is always the value of built in variable ORIGIN. So if ORIGIN=0 and you type x[12:25, then the 13th element of x will be 25, and the elements 0 through 11 will all be set to 0.

Richard

On 8/7/2009 7:30:59 AM, rijackson wrote:

>We don't need the real data. It's hard
>to figure out what you are trying to do
>when nothing actually works though. So
>either you put variable definitions at
>the top, or we have to.
>
>So please put in some variables with
>fake data.

Please, just ignore that stuff on the top then, it was a mistake putting it up, just refer to the picture as an example of my problem.


>
>Go to "Save As" and change the format to
>Mathcad 11.
>

Ok, thanks. Now I know!

>
>Yes. Change the nested vectors into
>columns of a matrix (so you have one x
>matrix and one y matrix)
>

How, sorry?

>
>The first element of the array is always
>the value of built in variable ORIGIN.
>So if ORIGIN=0 and you type x[12:25,
>then the 13th element of x will be 25,
>and the elements 0 through 11 will all
>be set to 0.

AAAAH! Thankyou! That makes things so much easier!

Neil


>I'll attach an example of the nested array size<<br> __________________________

Please, visit all the threads in this collab, not more than a week ago and find your solution, not specific to 14. From your picture, I doubt your case is specific, it should explode easily unless the creation is incorrect.

This forum is public.

jmG

On 8/7/2009 6:43:34 AM, NSizzle wrote:
== I'll attach an example of the nested array size

Does the attached worksheet help?

Stuart

That's really helpful Stuart, thanks.

Although is it possible to then add two more vectors to this matrix? one on either side. Theses should go in columns 1 and 64.

Also these vectors are of diffrent lengths (all between 149 and 300 values) does this not make the matrix...well, not a matrix?

Thanks,

Neil

See the attached worksheet

Richard

Hi Richard, thanks for the response.



I'm not really understanding this. I wish to plot my values side by side on a graph (i.e. they stick together) so if I were to plot my (currently) 64 y vectors agains my 64 x vectors then one big dataset will be formed.



Basically what I need to do now is stick all the ysub values together (this should be ysub(1) onto ysub(n) onto ysub(r_up=64 (in chronological order, on top of the other) to create one single big y array vector.



And exactly the same for the x components as they are the same length of their y components and in the same chronological order.



Then that should be it.

If that can't be done, a way to plot every ysub(n) against every xsub(n) would be just as good.


p.s. they cannot be defined as functions like a sinusoidal wave. Just treat them as independant data.



Thanks for your patience.



sorry for all the trouble,



Neil



(I really do appreciate all this)

>p.s. they cannot be defined as functions like a sinusoidal wave. Just treat them as independent data.<<br> _____________________________

The only thing we have from you is your image, a stack of nest of something , that can be anything. You must look for in this collab as advised before (few days ago) ... that you might figure if what you did invisible and confidential is exploitable or not. If you can produce a stack of nests, the first priority is to explode the project ... if you don't want to pass the real thing, make a fake as suggested before.

Resume:

1. Download my ARRAY utilities,
2. make a fake and save as 11 or lower.

jmG

Hi,

I'm sorry but i don't understand what difference it makes. For all it matters it is a nested array with n rows - n can be assumed random and >1 - and just the one column. Let's call this nested array Y.

Contained in each of these cells is a single vector - these lengths can be assumed random

I just want these arrays plotted basically atop each other creating one vector.

each value in every vector can be any value - so you may assume it's 1 for everything

Sorry if I'm being blindly ignorant but I honestly can't see how any other information I give you will help

Thanks,

NSizzle

>I'm sorry but i don't understand what difference it makes.<<br> ______________________________

The difference it makes is that your stack of nest might be conceptually wrong or incorrect, and we can't tell w/o at least a fake. If your equation or work is squaring the moon and so confidential, take another example. We must have a work sheet showing something. There are 100's if not 1000's of this type of stacked nests in this collab, none exactly the same but all exploitable and explodable as routine work. I doubt any collab will plug something correct but typical that you will come back and say not your right way, rather my wrong way and never seeing your wrong way.

jmG

...



jmG

On 8/7/2009 12:27:46 PM, NSizzle wrote:
>Hi,
>
>I'm sorry but i don't
>understand what difference it
>makes.

It makes a difference because it's not clear from your post what you want, and we don't have a lot to base our best guesses on. We have a non-working worksheet with undefined variables and a couple of bitmaps. The more information you give, the easier it is for us. All the regular posters here do this voluntarily, so the easier you make it to answer your questions, the more likely you are to get an answer. And the more likely it is that the answer will be what you want the first time round.

Richard

Hi,

I'm sorry but i don't understand what difference it makes. For all it matters it is a nested array with n rows - n can be assumed random and >1 - and just the one column. Let's call this nested array Y.

Contained in each of these cells is a single vector - these lengths can be assumed random

I just want these arrays plotted basically atop each other creating one vector.

each value in every vector can be any value - so you may assume it's 1 for everything

Sorry if I'm being blindly ignorant but I honestly can't see how any other information I give you will help

Thanks,

NSizzle

On 8/7/2009 10:55:22 AM, NSizzle wrote:

>p.s. they cannot be
>defined as functions like a
>sinusoidal wave. Just treat
>them as independant
>data.

The function is irrelevant. Stuart just used it to create vectors of data, because it's hard to show how something would work without at least some fake data.

You seem to be asking for two different things, which is causing a fair amount of confusion. Sometimes you seem to be asking to plot each x against each y, and other times you seem to be asking to create one large x and one large y, which are different things.

Is this what you want?

Richard

On 8/7/2009 3:10:41 PM, rijackson wrote:

>You seem to be asking for two different
>things, which is causing a fair amount
>of confusion. Sometimes you seem to be
>asking to plot each x against each y,
>and other times you seem to be asking to
>create one large x and one large y,
>which are different things.
>
>Is this what you want?
>
>Richard

That's exactly what I need! thankyou. To be honest Richard, either of thoes would have solutions I was asking for would have done the job but the solution you've posted is much better than lots of different plots!

There is only one problem I have foun with this bit of UnNest(x) code and that is that it creates the vector of the right length and then puts a zero in the first row. So instead of my vector, say v, of length 1500 (0 - 14999), I get a vector, say b, of length 15001 (0 - 15000)

Thanks so much for all the help and for persisting with my ignorance!

basically, as far as I can see, the V <-- vnaught command just puts a zero in the first cell and then creates the desired vector and stacks them. Is there an way to just have the vector without a cell at the start which just has the value n where V <-- n?

Ok I think I got it



does that seem right?



Thanks for all the help! I think that may be me done now!



Neil

The problem is not the UnNest function. In my reply to your first post I pointed out that the array origin in Mathcad is 0, not 1. When you create your nested vector though, your code assumes it's 1. That means the first element is not a vector, it's just a zero, so the UnNest function stacks 0, vector, vector, etc. The right solution is to rewrite the code that generates the nested vector.

Richard

On 8/17/2009 6:36:48 AM, NSizzle wrote:

>does that seem right ? [Neil]<<br> ______________________

NO, it does not ...@
http://collab.mathsoft.com/~Mathcad2000/read?127034,21e#127034
You are showing a stack, a stack of variable length (certainly not ending with [...] in the last cell for Mathcad version 11.2a and earlier. Each cell is a nest of 301 rows x 1 col. As explained before, what you are doing to get that stack of nest may be conceptually wrong, but if you don't want to "Save a" 11 or earlier, up to you. And you were advised to visit few days ago (at the time) for a utilities where all what you need is there.

jmG



Ok it is working so I don't know whether it's an unorthodox way to start from a different point than zero but it is much less of an effort to rewriting all my previous programming (which is a lot) that treats origin as the zero preset.



from the point that I have used your code richard, I have reset the ORIGIN to 1 to display like an excel sheet.



all done! brilliant! Thanks a lot everyone - especially richard.



By the way jmG, I don't understand to what you are referring here:





On 8/17/2009 7:55:14 AM, jmG wrote:

>And you were advised

>to visit few days ago (at the time) for

>a utilities where all what you need is

>there.

>

>jmG





Neil


If you want to start arrays at 1 then it is best to go to the worksheet options and set the array origin to 1. If you do that though, many of the functions posted here by various people will not work without modification (so in future I recommend getting used to origin 0).

Richard

You have the option of starting at an index of 1, type ORIGIN = 1, and you have reset the indexing to begin there.
Fred Kohlhepp
fkohlhepp@sikorsky.com

By the way jmG, I don't understand to what you are referring here:


On 8/17/2009 7:55:14 AM, jmG wrote:
>And you were advised
>to visit few days ago (at the time) for
>a utilities where all what you need is
>there.
________________________

If you read the collab regularly and all, the search tool is dead. So, I can't linked you to my own posting a little period before your first posting in this thread. That's what I'm telling you: visit a week or two ago your first post, all the posting in this collab and find a sheet called something like "Array utilities", you will need it at other times in other situations. Your indexing "band-aid" does not make sense by reading, but if it works for you today... fine ... END.

jmG

Excel has a default index for the first data entry as 1 (one), Mathcads default is zero (0). Changing the ORIGIN is easy and quick but you have to keep track of the table start index numbers, especialy for any range varible or looping program.
Announcements

Top Tags