Info

This question is locked. 編集または回答するには再度開いてください。

Deleting Some Specific Entries from a vector

1 回表示 (過去 30 日間)
Mücahit Özalp
Mücahit Özalp 2021 年 8 月 21 日
Locked: Rena Berman 2024 年 7 月 30 日
I have vectors xa and yb. I want to write the entries of yb to xa which are not the ones -1,0,1,0.6,-0.6,0.8,-0.8
I apply this one
xa=yb(yb~=1);
xa=xa(xa~=-1);
xa=xa(xa~=0);
xa=xa(xa~=0.6);
xa=xa(xa~=-0.6);
xa=xa(xa~=-0.8);
xa=xa(xa~=0.8);
But it just deletes -1,0 and 1. Not 0.6,-0.6,0.8,-0.8. Where do you think the problem is? Or how can I change it?
  1 件のコメント
Rena Berman
Rena Berman 2024 年 7 月 30 日

(Answers Dev) Restored edit

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 21 日
Just do with the following
q = abs(yb);
p = (q==0|q==1|q==0.6|q==0.8);
xa = yb(~p)
if it does not work, use a tolerance TOL
TOL = 1e-5
q = abs(yb);
p = (q<=TOL|abs(q-1)<=TOL|abs(q-0.6)<=TOL|abs(q-0.8)<=TOL);
xa = yb(~p)

その他の回答 (0 件)

This question is locked.

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by