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

invalid index

YA_10963798
11-Garnet

invalid index

How to solve this , the result should have the same values in z and qcza...

Why  Qcpt has different quantities it should have more than (6X1) l...ike the one in z and qcza

 

YA_10963798_0-1717581348624.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

If you make the changes I had shown and replace the wrong q.... you should get a result and your expression for Q.CPT should be a vector with 5 (not 6 because your range i.n runs only from 1 to 5) large vectors.

Did you notice the remarks i made at the end of my last answer?

Any value between 12 MPa and 15 MPa would be set to zero. If thats not your intention but you rater want that value to be unchanged, you cold add the green highlighted statement.

The result vectors still will have one element less than the input and its first element will always be zero because q[1 never gets assigned a value.

Werner_E_0-1717671892374.png

 

Maybe its an option for you not to use the range i.n  at all and use vectorization. That way all six vectors in q...anchors are used and not only the first five.

Werner_E_1-1717672073874.png

 

 

 

View solution in original post

15 REPLIES 15

Your program uses a loop running from O+1 to last(z).

ORIGIN is set to 1 and z is a vector with just six(!!) elements (each of them is a larger vector).

So the loop is just run 5 times and the result is a vector with just six elements, the first one is never defined and defaults to zero.

Here an example:

Werner_E_0-1717592225566.png

 

if you may have noticed that z is a matrics contains 6 matrics 

I want to write a program for each matrics is z 

Like the first row in z is a matric (1339X1) I want the function to be applied in all of them. 


@YA_10963798 wrote:

if you may have noticed that z is a matrics contains 6 matrics 

I want to write a program for each matrics is z 

Like the first row in z is a matric (1339X1) I want the function to be applied in all of them. 


Which function?

I don't see any function which could be applied to a 1338 element vector.

You could make the yellow highlighted change but then the function would fail because of the usage of the green highlighted  q.cza which only has 35 elements.

Werner_E_2-1717670993868.png

You may also reconsider the logic of your program. If both if-conditions fail, q.i is not assigned a value (and would default to zero). Is this really what you had in mind?

Furthermore, the result vector will now have one element less than the input vector and its first element will always be zero because it never gets a value assigned.

 

 

 

hmm I mistakenly wrote qcza it should be qcza;anchors in all of them . ( thanks for pointing that out)

 

I wrote funtion because I will be using the same operator in the following calculation. 

What I need is to implement this program to all the data I inserted in (qcza;anchors) and z 

not only for six times which is the number of rows in z but in all the rows values

If you make the changes I had shown and replace the wrong q.... you should get a result and your expression for Q.CPT should be a vector with 5 (not 6 because your range i.n runs only from 1 to 5) large vectors.

Did you notice the remarks i made at the end of my last answer?

Any value between 12 MPa and 15 MPa would be set to zero. If thats not your intention but you rater want that value to be unchanged, you cold add the green highlighted statement.

The result vectors still will have one element less than the input and its first element will always be zero because q[1 never gets assigned a value.

Werner_E_0-1717671892374.png

 

Maybe its an option for you not to use the range i.n  at all and use vectorization. That way all six vectors in q...anchors are used and not only the first five.

Werner_E_1-1717672073874.png

 

 

 

it works . thank you


@YA_10963798 wrote:

it works . thank you


Sure, but I also hope that it calculates correctly - that the results are what they should be.
I am still concerned about the first value always being zero and the last one missing - but then maybe this does not matter at all.

No problem. I will try to tackle these issues
Thanks 🙏

YA_10963798_1-1717680957588.png

Why I'm getting zeros;(

 

 

 

LucMeekes
23-Emerald III
(To:YA_10963798)

Because your function contains a loop that is executed for only ONE value of n, namely the index of the last element of this P..... vector.

Due to your picture (you should attach the worksheet!) I cannot see what the expression under the vectorisation is, but if it multiplies o with that element of array P... and with the variable thickness, then the result could very well be an array of elements all 0 (zero), because I suspect that o may be defined as 0.

 

Success!
Luc

You find it in last page 

You sure meant a loop like

Werner_E_1-1717685032568.png

 

For the rest, as Luc already said, we would need to see the current version of the sheet.

o is defined as 1.49 m in the originally posted sheet.

"thickness" is not defined there. I guess this is a single scalar and vectorization in the program would not be necessary.

 

I guess that your function F(..) could be written in a very simple way:

Werner_E_0-1717686141902.png

 

Note that the formal parameter of a function can have any name (I have chosen P for simplicity) - it must NOT be the very same name of the actual parameter used when you later call the function.

 

 

I wrote thickness 

you will find it in last page

OK, so thickness is a nested vector as well. In this case your function F must have TWO arguments as otherwise there is no way to tell Prime which of the six vectors in "thickness" it should use.

One way to do so is (no vectorization in the program is needed as yu are just multiplying scalars):

Werner_E_0-1717691285484.png

 

But your function F still can be written simpler - this time vectorization is needed!

Werner_E_1-1717691419729.png

 

 

I see 

Thank you so much 

 

 

 

Top Tags