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

Problem in Matrix Row addition

sgarg-2
7-Bedrock

Problem in Matrix Row addition

Hi Everyone

Please help me to add row of any Matrix array. I am able to add individual but in my example case I am unable to do so. Please help in this regard.

Find attached sheet for your reference.

ACCEPTED SOLUTION

Accepted Solutions
sgarg-2
7-Bedrock
(To:sgarg-2)

Hello Everyone

Thanks for your kind response. Finally I have solved the problem. All solution provided by you are correct. The addition of row was correct but my interpretation was wrong( I apologize !!)  and I was treating the result as a wrong result. In  "MATH FORMATTING" option on changing result format from general to Decimal solved my problem. The result was showing exact zero instead of some higher power of 10.

Thanks again for your kind support.

Untitled.png

View solution in original post

22 REPLIES 22
Werner_E
25-Diamond I
(To:sgarg-2)

I can't open Prime 3.1 files, but maybe these two approaches can help

StuartBruff
23-Emerald III
(To:Werner_E)

... Noting, en passant, that Prime has a row operator as well as a column operator, which makes life much simpler for extracting and operating on arrays (avoids all that nasty transposition to get at a row!).

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Ooops, I confused column sum with row sum!

This is what it should have been

Hi Werner

Your given solution does not work. Please find attached sheet for your reference.

Untitled.png

StuartBruff
23-Emerald III
(To:sgarg-2)

An alternative to programming is to use Mathcad's matrix maths capability.

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Here is an ORIGIN independent variation of your method:

Werner

Hi Werner

Your response was in comfort zone but unfortunately it doesn't work for me. Please do the needful. Find attached sheet for your reference.

Untitled.png

LucMeekes
23-Emerald III
(To:sgarg-2)

You mean, to add a row to the matrix in the P(t) formula?

Do as shown here:

That is, place your cursor on the matrix element below or above which you want to add a row, then choose either 'insert below' or 'insert above' from the ribbon, and a row will be added (below or above respectively).

Success!

Luc

sgarg-2
7-Bedrock
(To:sgarg-2)

Hello All

Thanks for your response. I made some more clarification on problem. Please find attached sheet for your reference as well.

Problem.png

Thanks

LucMeekes
23-Emerald III
(To:sgarg-2)

So with:

You get V.dc[1 to contain a vector with as first element the sum of all values on the first row of Z[1, the second element of V.dc is the sum of all values on the second row of Z[1, etc.

It shows as:

It tells you that V.dc[1 is an array with a single element, that element is a 3-element vector. It's nested.

To see the actual values, you can ask to display the first element of this vector:

Or you can select the expression and use the option Collapse Nested Matrices from the Matrices/Tables ribbon in 'Result format' at the far right. Then it shows like:

(A vector, nested in a vector).

Now if you do this for all k, you get:

or, expanded:

Does this help?

Luc

Hi LucMeekks

The main problem is result. If you observe that the sum of row for Z1 is not correct as it would be.The same solution works well with other example but in my example case it is not giving correct result? 

LucMeekes
23-Emerald III
(To:sgarg-2)

But if you want the total sum, you can just do:

And if you want to check if all (3) row sums are close to zero:

Is this what you're after?

Success!

Luc

Werner_E
25-Diamond I
(To:sgarg-2)

I am not sure if I understand correctly what you are after.

You have a vector Z with 49 elements and each of those elements is a 3 x 3 matrix.

Your goal is to do what I had done for 1 matrix with all 49?

So the result would be a vector of again 49 elements but each element would now be a 3 x 1 matrix consisting of the sums of the three rows in the corresponding 3x3 matrix.

Is this correct?

What you show 9:20 PM should work that way. Simply get rid of the vector brackets on the RHS of the definition of V.dc_k.

You should also turn on the feature to display nested matrices like Luc had shown if you want to see the whole vector V_dc at once.

If you would like the results in a differnt format like a simple 3 x 49 matrix or something else, you should say so.

If we misintrepeted you intention completely you should  probably better provide a sample, complete with the exact output (which you would have to type in manually) you expect.

Werner

Werner_E
25-Diamond I
(To:sgarg-2)

Here are some useful functions, if our guess concering your goal was correct.

This time the functions expect a vector of matrices as argument.

In rSums2 all those matrices must concist of the same number of rows.

Werner

sgarg-2
7-Bedrock
(To:sgarg-2)

Hello Everyone

Thanks for your input. I am surprised to see, all above suggestions are giving correct result for any arbitrary matrix but in my example case it is giving wrong result. Again I am trying to explore my problem statement in detail (Find attached sheet for your reference) . Hope it help. Please do the needful. Tons of thanks in advance.

Untitled.png

StuartBruff
23-Emerald III
(To:sgarg-2)

Hi Sameer,

Unfortunately, I don't have Prime available, so cant' check what's going, but using displayed values for Z, Mathcad 15 seems to give the expected results using the formula you use in an earlier thread (Werner's variation of the matrix method):

Try importing the attached Mathcad 15 into Prime and see if you get the same results in Prime as in M15.

Stuart

Hi, This is what do you want?

Best regards.

Alvaro.

sum.gif

Werner_E
25-Diamond I
(To:sgarg-2)

Did you use the method shown on Aug 25, 2016 9:20 PM  but without the matrix brackets?

Looks like the first two rows are calculated correct but the last simply returns one of the three values and not their sum.

Unfortunately I can't read P3.1 files and the machine, I usually remote connect to give 3.1 a try is down at the moment and I am too lazy to travel there to turn it on.

So I am restricted to the screenshots or pdf prints of your worksheet and that you answer the further enquiries.

LucMeekes
23-Emerald III
(To:sgarg-2)

I don't know what you think is wrong with your 'sums', especially considering the input:

The rowSum() program is fine. But do notice that in the definition of V.dc[k you put in 1/3....!

Luc

Werner_E
25-Diamond I
(To:LucMeekes)

> in the definition of V.dc[k you put in 1/3....

Ahh! I could not open the file and the screenshot did not show it. That explains the effect pretty well.

But we are poking around for more than two days now and still Sameer is not able or willing to clearly say WHY a produced result ist wrong in his opinion and WHAT exactyl he would have expected instead. So I think its better to spend no time any further in guessing what he could mean and what he would need.

WE

sgarg-2
7-Bedrock
(To:sgarg-2)

Hello Everyone

Thanks for your kind response. Finally I have solved the problem. All solution provided by you are correct. The addition of row was correct but my interpretation was wrong( I apologize !!)  and I was treating the result as a wrong result. In  "MATH FORMATTING" option on changing result format from general to Decimal solved my problem. The result was showing exact zero instead of some higher power of 10.

Thanks again for your kind support.

Untitled.png

LucMeekes
23-Emerald III
(To:sgarg-2)

While the results of your equations might give results of exactly 0 when analysed exactly, I'm afraid your interpretation is not correct.

In choosing a different display format for your results, you've limited their accuracy. Choosing 'decimal' means that exponential notation will not be used, and you are limited to 15 decimals.

That means that any smaller results are discarded, hence you get 0.

Suppose you had calculated exp(-x) with x large enough:

In the first evaluation, the general display method is used, the second is limited to decimal.

Would you argue that exp(-37) is exactly 0?

Now in your case the results may actually be exactly 0 when analysed analytically, but the numeric calculation that you did resulted in (some) values close to 0, but not exactly 0 because of the limited numerical accuracy.

If you want proof that they actually are 0, you should use symbolic evaluation of your equations.

Success!
Luc

Announcements

Top Tags