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

WRITETEXT: This value must be an integer error

Cornel
18-Opal

WRITETEXT: This value must be an integer error

Hi,

How to export f(tj) in a txt file?

Cornel_0-1717772152008.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Cornel)

simply delete the vector index j in WRITETEXT. Depending on the nature of your function f it might be necessary to apply vectorization. In case of your simple identity function f(x):=x it would not be necessary, but I would always apply vectorization in such situations.

Werner_E_1-1717780281727.png

As you can see there is no need for any range variable.

If your main intention was to just use the first 501 elements of the 1001 element vector, you would have to use the "submatrix" function:

Werner_E_2-1717780544146.png

Even another option is to parametrize t;

Werner_E_3-1717780767048.png

Depends on your use case and personal preferences which option to choose.

 

What you did is a misuse of a range variable. A range variable is an implicit loop, kind of programming.

f(t[j) is an invalid object - you can see this when you try to assign it a variable using F:=f(t[j). You will get an error message doing so.

Of course you could write F[j := f(t[j) and this would work OK because now the range j is used for one of its three use cases, indexing a vector/matrix.

 

BTW, here is an alternative to create a vector like t

Werner_E_0-1717780241733.png

 

View solution in original post

1 REPLY 1
Werner_E
24-Ruby V
(To:Cornel)

simply delete the vector index j in WRITETEXT. Depending on the nature of your function f it might be necessary to apply vectorization. In case of your simple identity function f(x):=x it would not be necessary, but I would always apply vectorization in such situations.

Werner_E_1-1717780281727.png

As you can see there is no need for any range variable.

If your main intention was to just use the first 501 elements of the 1001 element vector, you would have to use the "submatrix" function:

Werner_E_2-1717780544146.png

Even another option is to parametrize t;

Werner_E_3-1717780767048.png

Depends on your use case and personal preferences which option to choose.

 

What you did is a misuse of a range variable. A range variable is an implicit loop, kind of programming.

f(t[j) is an invalid object - you can see this when you try to assign it a variable using F:=f(t[j). You will get an error message doing so.

Of course you could write F[j := f(t[j) and this would work OK because now the range j is used for one of its three use cases, indexing a vector/matrix.

 

BTW, here is an alternative to create a vector like t

Werner_E_0-1717780241733.png

 

Top Tags