How to code below mathematical formula?
3 ビュー (過去 30 日間)
古いコメントを表示
I want to implement a below mathematical function in MATLAB, can anyone help me out?
0 件のコメント
採用された回答
その他の回答 (1 件)
KALYAN ACHARJYA
2019 年 7 月 3 日
編集済み: KALYAN ACHARJYA
2019 年 7 月 3 日
x= %define x value range
n= %define n
threshold= %define threshold value
fx=x;
idx1=find(fx>=threshold);
fx(idx)=1;
idx1=find(fx<threshold);
fx(idx)=0;
MYOP=(sum(fx(1:n)))/n;
2 件のコメント
Stephen23
2019 年 7 月 3 日
編集済み: Stephen23
2019 年 7 月 3 日
Note that this answer does not implement the formula given in the question.
In particular it does not include f(x) in any way within the sum, as the question indicates. It also does not vectorize the generation of fx (or use a loop), so it is unlikely to be a useful approach anyway.
The code throws an error when run because xi is not defined:
Undefined function 'xi' for input arguments of type 'double'.
参考
カテゴリ
Help Center および File Exchange で Function Definition についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!