Effacer les filtres
Effacer les filtres

Delete and merge rows and columns based on values of other matrix under looop

1 vue (au cours des 30 derniers jours)
vimal r
vimal r le 24 Fév 2020
Commenté : Turlough Hughes le 24 Fév 2020
i have a matrix of A and B1 B2 B3....Bn condition is to check B1 if zero then eliminate the rows and columns in matrix A store as A1 then it should go to B2 check and store in A2 till An.
A is nxn matrix
B1 B2.....Bn is a 1xn
Example:
if any of the element in B1 matrix is zero suppose element 3 it should eliminate 3rd row and 3rd column of Matrix A and store as A1
and it has to loop till Bn and store An matrices.
  5 commentaires
vimal r
vimal r le 24 Fév 2020
i have to store An matrix loop should end n variable output of A1 ....An based on the condition of Bnxn each row as one senario...
my input is Anxn and Bnxn
take first row of B check zeros and based on that it should eliminate rows and columns in matrix A and store as A1
then go to second row of B check and based on zero eliminate rows and columns in matrix A and store as A2
so on.....
Turlough Hughes
Turlough Hughes le 24 Fév 2020
The code I provided above does what you ask with the exception of working through columns of B as opposed to rows of B because I did not have enough info at the time... that's is a simple fix. Having variables numbered A1 to An is a sign that you are doing something wrong because you either have to copy and paste code or use the eval function to generate these variables.
The results in the example I provided above are stored in a cell array which is in my opinion the easiest alternative to generating n variables. The results are then equivalently stored as
An{1,1}, An{1,2} all the way up to An{1,n}.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by