Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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
Solved! Go to Solution.
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.
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:
With the matrices ppal used:
Like this???
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.
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.
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:
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.