Assigning an opertation vector to a variable
古いコメントを表示
Hello there!
I am trying to assign this vector
v(mod(v,2)~=0)=0
The operations is supposed to replace odd numbers in a vector with 0. I am trying to assign this vector to result variable in a function.
This got an error:
v(mod(v,2)~=0)=0 = result;
回答 (1 件)
James Tursa
2015 年 3 月 15 日
Is this what you want?
function result = myfunction(v)
v(mod(v,2)~=0) = 0;
result = v;
return
3 件のコメント
Le Borge
2015 年 3 月 15 日
Le Borge
2015 年 3 月 15 日
編集済み: James Tursa
2015 年 3 月 16 日
James Tursa
2015 年 3 月 16 日
Is this what you want?
function [result1,result2] = myfunction(v)
result1 = v;
result1(mod(result1,2)==0)= 0;
result2 = v;
result2(mod(result2,2)~=0) = 0;
return
end
カテゴリ
ヘルプ センター および File Exchange で Function Creation についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!