Create a Matrix from a Matrix

scorpione

New Member
Joined
Apr 23, 2013
Messages
6
Hi everybody,

Below there are all the information needed to understand my problem. I tried to find something similar in the forum, but I couldn't.

M(1 to R,1 to C): matrix with R rows and C columns [element known]
M(i,j): elements of the matrix M in position i(row)-j(column) [element known]
n<r [element="" known]
N(1 to n, 1 to C) [element unknown]

N is made of all the rows of the matrix M that have in the column i a specific value.

How is it possible to create such matrix?


Below there is an example of matrix M and N: the specific value in the column 2 (i) is C

</r>
[TABLE="width: 284"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]M[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]0.1[/TD]
[TD]C[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]0.2[/TD]
[TD]A[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]0.1[/TD]
[TD]C[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]0.4[/TD]
[TD]C[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]0.5[/TD]
[TD]B[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0.6[/TD]
[TD]C[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]N[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]0.1[/TD]
[TD]C[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]0.1[/TD]
[TD]C[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]0.4[/TD]
[TD]C[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]0.6[/TD]
[TD]C[/TD]
[TD]30[/TD]
[/TR]
</tbody>[/TABLE]
<r [element="" known]




Grazie
Scorpione</r>
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
please upload a sample file (with current data and desired result) on a sharing site, then paste the link here
 
Upvote 0
Ciao patel45,

unfortunately I cannot share any information (they are quite strict here): the example made is not enough to clarify what I need?
 
Upvote 0
Hi everybody,

I found this solution that seems to work:

BrokersMatrix (1 to MatrixRows, 1 to MatrixColumns) = M(1 to R, 1 to C)
BrokeNumber = n<MatrixRows
TariffMatrix (1 to BrokerNumber, 1 to MatrixColumns) = N(1 to n, 1 to C)

Column 3 of the BrokersMatrix is the column where is written the tariff and that I want to be equal to the variable "Tariff"


Dim TariffMatrix() As Variant
ReDim TariffMatrix(1 To BrokerNumber, 1 To MatrixColumns)
q = 0
For i = 1 To MatrixRows
If BrokersMatrix(i, 3) = Tariff Then
q = q + 1
Else
q = q
End If
If BrokersMatrix(i, 3) = Tariff Then
For j = 1 To MatrixColumns
TariffMatrix(q, j) = BrokersMatrix(i, j)
Next j
End If
Next i


If anybody knows a simpler way to solve the problem, please let me know it!

Grazie
Scorpione
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,239
Messages
6,123,816
Members
449,127
Latest member
Cyko

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top