필터 지우기
필터 지우기

matrix 0f {0,1}

조회 수: 2 (최근 30일)
Sara
Sara 2022년 12월 11일
댓글: Sara 2022년 12월 11일
i have a matrix B=M*K /M=36 ,K=10 i will sort this matrix in descending -[x , I] = sort (B , 'descend') and i want to take the elements (1:4) for vector M and check for element by element for vector K -for i = 1:K -u=X(1:4,i) and i have constraint for i -if i satisfy constraint then i have to put ones for these (1:4) M elements and give a zero to the other elements of M how can i do this ? how can i give ones to (1:4) elements and zeros to the rest of the elements of this vector M
  댓글 수: 2
Jan
Jan 2022년 12월 11일
The question is not clear. Is "b" the same as "B"? If M and K are vectors, which dimensions do they have to let B be a matrix? If K is a vector, what does "for i=1:K" mean? What is X?
Sara
Sara 2022년 12월 11일
I edit the question and put the values of M and K / and i is one of the elements of K vector The loop i= 1:K means that i want to check for all K elements vector/ and X is the sorted of B

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

답변 (1개)

John D'Errico
John D'Errico 2022년 12월 11일
About as confusing a question as I could imagine, but after reading it several times, I will make a guess.
I think in the end, you just need to learn how to set a column of a matrix where the first 4 elements are 1, and the remainder of the elements are 0. I think that is all you are asking. Somehow, I doubt I am right. But that is my conjecture. Anyway, do this:
x(:,i) = [ones(4,1),zeros(M-4,1)];
  댓글 수: 1
Sara
Sara 2022년 12월 11일
Thanks for your effort i will try this

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by