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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

Multiplying an array by a number

CN_13593194
10-Marble

Multiplying an array by a number

whenever I multiply an array by numbers and store it in an array I get this:

CN_13593194_0-1750958016402.png

 

because of those brackets, if add other values to u''0 and I try to call u''0 and displays like this:

CN_13593194_1-1750958110180.png

 

why is that happening and what is the proper syntax to avoid this issue?

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:CN_13593194)

Now that you have attached the sheet we see that the problem actually is what I already wrote twice - you are missing the vector index when using "k"

Werner_E_1-1750967873804.png

There are also further vector indices missing

Werner_E_2-1750968193317.png

 

 

 

 

View solution in original post

8 REPLIES 8
Werner_E
25-Diamond I
(To:CN_13593194)

Can't say for sure without seeing the sheet (which you if ever possible always should attach and say which Prime version) but it seems to me that you are using the wrong type of index when you define k0, t0, u0, etc. You seem to be using the vector/matrix index ans so you are creating a 1x1 matrix. You should rather use the literal index (keyboard short is Ctrl+-) so the zero is just a subscripted part of the name and not the index of a vector.

Or did you intend to create matrices (arrays)? Then you will have to be more concrete in explaining what exactly is the concern.
If creating arrays was done one purpose but you expected a normal numerical result for u"0 in your first picture, the reason you get a 1x1 matrix result is the usage of k instead of k0.

I see no reason for the effect in your second picture unless you somewhere have defined a value for u"1.

yes, I am using the vector/matrix index, because they are supposed to be vectors

I attached the file

I am using prime 9.0.0.0

what is strange to me is that if I put 'c', 'k' and 'm' as vectors, then the result for u''0 comes as a number and not a 1x1 vector.

 

what I am trying to avoid is this: 

CN_13593194_0-1750958941295.png

this is useless to me. So I am trying to figure out what is wrong in my syntax to avoid it

Werner_E
25-Diamond I
(To:CN_13593194)

As already written above the problem may be the usage of simply k instead of k0 in your expression for u''0.

And I still see no reason why u'' should be a 2x1 vector as shown in your picture. As far as you had shown you never had defines u'' as a vector with more than one element - you never had defined u''1.

So I guess that you did not show all you have done and I only can repeat that you should attach the worksheet instead of just showing pictures.

BTW, to see the values in your nested vector u'' you can turn OFF "Collapse Nested Matrices" on the "Matrices/Tables" tab (section: "Result Format").

LucMeekes
23-Emerald IV
(To:Werner_E)

The OP attached the worksheet to the original message...

LucMeekes
23-Emerald IV
(To:CN_13593194)

You should:

1. State which version of Prime you are using.

2. Attach the worksheet (.mdcdx file).

3. Realise that there are two kinds of 'things' that result in a sort of subscript:

    a A literal subscript, which you get by typing [Ctrl-_] (That is, depressing the [Ctrl] key and then hitting the [_] key, the 'underscore'). This creates an extension to the variable. Example: variablesubscript.

   b An index (into a vector, a matrix or an array) you get this by typing a "[" (opening square bracket) followed by the index. If you look closely, when the cursor is on the expression with the index, you'll see a faint square bracket.

 

Now, without your worksheet I have to guess, but my guess is that you've created u0 using the [, this means that u is a single element vector, and 0 is the index to that (first) element.

The result you get for u'' is a two element vector, where each of the two elements is a one element vector.

 

Success!
Luc

 

I am aware of the difference mentioned.

 

as I said, the use of the vector subscript is intentional.

 

however, I still dont want to obtain [1x1] when I call the vector. I need to see the actual number in the vector.

Werner_E
25-Diamond I
(To:CN_13593194)

Now that you have attached the sheet we see that the problem actually is what I already wrote twice - you are missing the vector index when using "k"

Werner_E_1-1750967873804.png

There are also further vector indices missing

Werner_E_2-1750968193317.png

 

 

 

 

Announcements


Top Tags