How to generate a matrix whose rows numbers are not elements of a given row vector

1 回表示 (過去 30 日間)
Hi all, pls i want generate a matrix from a matrix A of size m x n whose rows number cannot be an element in a row vector v = [v1 v2 .....vk]. Thanks
  2 件のコメント
Andrei Bobrov
Andrei Bobrov 2013 年 6 月 10 日
Give a simple numerical example.
Hugo
Hugo 2013 年 6 月 10 日
Could you please be a little more specific?
1) What does it imply "to generate a matrix from a matrix A"? What constraints do that impose to the generation process of the new matrix?
2) What do you mean by rows number: Each element in each row of the new matrix or the whole row?
In principle, you can always generate a matrix using a random number generator, like rand(m,n) or randn(m,n) (among others). The probability of any element of that matrix to be an element of v is almost zero, depending on the numerical precision. Even if you happen to find one element that is in v, you can again generate another number (or another matrix) using the random number generator.
Best regards

サインインしてコメントする。

採用された回答

Jim Hokanson
Jim Hokanson 2013 年 6 月 10 日
The following code should do what you want.
use_row = true(1,size(A,1));
use_row(v) = false;
B = A(use_row,:);

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 6 月 10 日
out = A(setdiff(1:size(A,1),v),:);

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by