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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Element by element division in matrix

KAL_1625
9-Granite

Element by element division in matrix

Hi Team,
I know it is a long shot. But I hope there is a way to do this. Suppose I have 2 matrix with very different number of rows and columns, say A is M x N and B is L x K. How can I divide each element of A matrix with every element of B matrix and Have it in a form of Matrix.  I am trying few things with nested for loops but have had no luck yet.

Thanks in advance,

Kadhir

KAL_1625_0-1655941002524.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

I actually found a way to do what I need. But it shows matrix within a matrix with just number of rows and columns. How can I make it to display the entire matrix showing up with values. I have to display each matrix using index.

KAL_1625_0-1656001578280.png

 

View solution in original post

10 REPLIES 10

What data structure would you expect as a result? An M x N matrix where each element is an L x K matrix??

 

You may consider not only to show the two input matrices but, more important, the expected result! And then also attach the worksheet itself.

 

@Werner_E Yes I exactly expected what you are saying. A M x N matrix where each element is L x K matrix.


@KAL_1625 wrote:

@Werner_E Yes I exactly expected what you are saying. A M x N matrix where each element is L x K matrix.


Hmm!!?? But thats quite different from what you answered to ppal where you, too, said that this is exactly what you want the solution to look like!??

Anyway, here is a function which will create this huge result matrix:

Werner_E_0-1656006351080.png

 

With the matrices ppal used:

Werner_E_1-1656006386025.png

 

 

 

ppal
17-Peridot
(To:KAL_1625)

Like this???

ppal_0-1655952082041.png

 

ppal_2-1655952155948.png

 

KAL_1625
9-Granite
(To:ppal)

This is exactly how I want my solution to look alike, but for some reason, my worksheet is showing error stating that the variable i and j should be scalar or matrix.

KAL_1625_0-1656000737809.png

 

I actually found a way to do what I need. But it shows matrix within a matrix with just number of rows and columns. How can I make it to display the entire matrix showing up with values. I have to display each matrix using index.

KAL_1625_0-1656001578280.png

 

OK, thats now the third, DIFFERENT display which you claims to be what you are looking for.

In my suggestion the division of an M x N by a L x K matrix results in a M x N matrix (with the elements being L x K matrices).

Your solution here results in a L x K matrix with elements being M x N matrices.

Thats quite different so I wonder what you really are looking for.

 

Anyway, the reason why the nested matrix is just shown collapsed is because this is the default display in Prime.
You may change it via the menu:

Werner_E_2-1656007124401.png

 

Thanks, I was not aware of this. thanks for bringing into my attention. To answer your question, the matrix solution that I created up there is what I was looking for. I thought it was very much implied. 


I thought it was very much implied. 

Not really IMHO. In a reply to my post you wrote "A M x N matrix where each element is L x K matrix." but finally you were looking for the opposite 😉

Anyway, glad you finally got a solution for your problem.

 

BTW, your last but one solution failed because of the wrong usage of the ranges (same applies to ppals solution).
You can display the results generated that way (as ppal has done) but you can't assign the output to a variable or use it later otherwise.
So when writing a program, never use ranges other than the range in a for-loop.

Hi,

Is this what you intend?

Capture.JPG

 

Top Tags