필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
vimal r
vimal r 2020년 2월 24일
댓글: Turlough Hughes 2020년 2월 24일
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
vimal r
vimal r 2020년 2월 24일
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 2020년 2월 24일
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}.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by