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

Translate the entire conversation x

The label is undefined

YA_10963798
14-Alexandrite

The label is undefined

Hi there,

Any ideas why this is wrong? I made f as function of M in order to define it 

YA_10963798_0-1764241005355.png

Regards

Yusra

ACCEPTED SOLUTION

Accepted Solutions

You've still got the "=" sign at the end of the function definition, Yusra.  You need to go to the very end of the function definition (Fn-right-arrow), then press Backspace twice.  That should remove the equal sign.

 

Stuart

View solution in original post

14 REPLIES 14

Try getting rid of the following equals sign in the function definition

Fred_Kohlhepp_0-1764246383840.png

 

still the same 

YA_10963798_0-1764254556090.png

 

You've still got the "=" sign at the end of the function definition, Yusra.  You need to go to the very end of the function definition (Fn-right-arrow), then press Backspace twice.  That should remove the equal sign.

 

Stuart

YA_10963798
14-Alexandrite
(To:StuartBruff)

So I can't put (=) in the function . Thank you for that I didn't know  

Now I have this another error that I always get . Can you explain to me how to tackle it 

YA_10963798_0-1764260146276.png

 


@YA_10963798 wrote:

So I can't put (=) in the function . Thank you for that I didn't know  


 

No worries.

 


@YA_10963798 wrote:

Now I have this another error that I always get . Can you explain to me how to tackle it 

YA_10963798_0-1764260146276.png


Without the worksheet, I'd be flying blind, but my first airport of call would be to check whether dzontgr is the same length as g`ontg.

 

Stuart

Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

So I can't put (=) in the function .

 


Not after a function DEFINITION.

An = means a numeric evaluation. Which numeric result would you expect here:

Werner_E_0-1764298058276.png

Prime can't know which value to use for "x". Even if a variable "x" is defined in front it won't work, because the "x" used in the right hand side of the function definition is NOT the "x" you may have defined in front but rather is the "x" used on the left hand side of the definition (formal function argument).

So when you DEFINE a function you can't evaluate this definition numerically. But after the definition, when you CALL the function providing a specific value for the formal argument you evaluate this function call numerically.

Werner_E_1-1764298365965.png

Actually you CAN evaluate a function definition using symbolic evaluation.

Werner_E_2-1764298431991.png

But this will not always work OK. If the function definition contains a boolean expression using the function argument(s) it can't decide its truth value without knowing specific values and so will refuse to evaluate symbolically

Werner_E_3-1764298609169.png

 


Now I have this another error that I always get . Can you explain to me how to tackle it 

YA_10963798_0-1764260146276.png


I also suspect that vector dzontgr contains not more elements than vector σ'ontg.

So when in your loop "i" reaches the index of the last value of σ'ontg, there is no element with index i+1 in vector dzontgr.

Probably the same applies to vector γ'ontg.

If all the mentioned vectors are of the same length the error should go away if you use    for i ∈ ORIGIN..last(σ'ontg)-1

The resulting vector returned by your function will have one element less than the vectors used. You have to decide if that's what you need.

YA_10963798
14-Alexandrite
(To:Werner_E)

Thank you Werner for the thorough explanation. 

when I use ( 

YA_10963798_0-1764322273520.png

won't that exclude the last value? 

When I did what you said .. I got this value with unit in the second raw ? 

YA_10963798_1-1764322827636.png

f2 must be unitless because the units should cancel each other 

YA_10963798_2-1764323186658.png

YA_10963798_3-1764323713996.png

 

 

Regards

Yusra

Werner_E
25-Diamond I
(To:YA_10963798)

OK, now we see that all the vectors involved consist of two elements only

The reason that the result of your function f2 is still a 2x1 vector and not just a single value inside a 1x1 matrix/vector is the first line in your function definition, R <- M.

So when you use last(..)-1 the calculation is only done for the first element and the second(last) element of R is not calculated at all but rather is the second(last) element of M unchanged - that's the reason you see unit Pa.

If you delete this first program line the result will be a unitless value, but in a 1x1 vector - as I wrote before, one element less than the vectors involved.

 

The the main problem still is: The calculation von R.i uses the elements with index i from some of the vectors, but also the element with index i+1 from some other vectors.

So when you tried to calculate R.2 this calculaton would use the elements with in index 2 of some vectors but also the elements with index 3 of some other vectors. And these vectors only have 2 elements so there is no element with index 3, hence the error you got.

 

You have to know how to deal with that problem, what exactly you are trying to calculate and how to deal with the last value in T in case you expect the outcome of the function f2 to be a 2x1 vector as well.

YA_10963798
14-Alexandrite
(To:Werner_E)

Yes you are right . I will fix that 

Thanks 

YA_10963798
14-Alexandrite
(To:Werner_E)

How can I exclude the first value not the last one ?

I tried to put the first one as 0  so now I have 3 values in each element .. I need it to calculate the second and the third (the last values )

YA_10963798_0-1764326692717.png

 

Werner_E
25-Diamond I
(To:YA_10963798)

Which first value?

 

Can you post a sheet which only includes this function, the needed vectors and show manually what you expect as the result?

generally if you want to delete the first value in a vector you could use the 'submatrix' function (assuming ORIGIN=1): v:=submatrix(v, 2, last(v), 1, 1)

But I am not sure if that is what you are trying to achieve.

 

> I tried to put the first one as 0 so now I have 3 values in each element .. I need it to calculate the second and the third (the last values )

?? third value?? The calculation of the third value would use the non-existing fourth value of some vectors and you would end up with the same problem as before. But maybe I misunderstood something.

 

BTW, as far as I can tell there is no need to divide by MPa as the units would cancel anyway also without doing so.

YA_10963798
14-Alexandrite
(To:Werner_E)

the matrixes I have  is for 2 layers , so  2 rows and I'm trying to calculate f2 for the two rows so I should have as a result two values for f2 ..

the problem I have is the f2 for the first value should be calculated from previous layer which is not there so I added this layer as zero values for all the vectors in this function. now I have three layers .. I want to get f2 for the second and the third layer assuming that the first one is zero 

 

when I use ( last -1) it exclude the last layer which I need . I want it to exclude the first one which is zero and still be able to use the same loop (for) 

YA_10963798_0-1764332782087.png

I attached the sheet

thanks

 

Werner_E
25-Diamond I
(To:YA_10963798)

You have to see if the modifications I made yield the result which you expect.

I changed the units of the vector gamma from Pa to Pa/m

I left your loop running from ORIGIN+1 up to last sigma'), but I changed all indices by subtracting 1. i->i-1 and i+1->i

I also changed the running index in your sum from i to k as i is already used for the upper limit of the sum.

Apart from that, I only removed unnecessary parentheses and the vectorization.

 

You have to check if the results are the correct values you expected.

 

YA_10963798
14-Alexandrite
(To:Werner_E)

Ok thanks 

Announcements

Top Tags