フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by