フィルターのクリア

function creating new vector

2 ビュー (過去 30 日間)
Lee
Lee 2013 年 5 月 3 日
i need to create a function that has an input of vector with 10 elements and it creates a new vector containing only elements between 0 and 1 times 2 minus 1 i cant figure out what i did wrong
function likelehood=like(x) counter=0; w=zeros(1,10); for i=1:10 if 0<x(1,i)<1; counter=counter+1; w(1,counter)=(2*x(1,i)-1)+w(1,i); end likelehood=w; end

回答 (2 件)

Carlos
Carlos 2013 年 5 月 3 日
編集済み: Carlos 2013 年 5 月 3 日
if 0<x(1,i)<1
should be
if x(1,i)>0 && x(1,i)<1

Youssef  Khmou
Youssef Khmou 2013 年 5 月 3 日
hi, try this function :
function y=likelihood(x)
T=x((x>0)&(x<1));
y=2*T-1;

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by