how to compare 2 vectors with same size , but columns is not always the same

1 回表示 (過去 30 日間)
Roger
Roger 2014 年 9 月 12 日
回答済み: Roger 2014 年 9 月 12 日
foreach element if a> b, set to 1;if a<=b ,0
if true
training = rand(rownum,n);
origpoint= [a1,a2];
for i = 1:rownum
for j = 1:n
if training(i,j)<= origpoint(j)
Qzone(i,j)=0;
else
Qzone(i,j)=1;
end
end
end
end
my problem is origpoint may have 4 or more elements, so 2 loops may not make it ,
like when origpoint =[a1 ,a2,a3],it needs 3 loops, training an origpoint have the same columns;but if more an , how to figure out
  1 件のコメント
Star Strider
Star Strider 2014 年 9 月 12 日
We need an illustration of what you want to start with and what you want as a result. It’s not clear.

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

採用された回答

Roger
Roger 2014 年 9 月 12 日
i got it ,
if true
training = rand(rownum,n);
origpoint= [a1,a2,...,an];
for i = 1:rownum
Qzone(i,:)=training(i,:)<= origpoint(:);
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by