フィルターのクリア

Trouble with using the function 'solve' to obtain decision boundary

2 ビュー (過去 30 日間)
nazneen
nazneen 2015 年 2 月 3 日
コメント済み: Star Strider 2015 年 2 月 20 日
I need to find the point where the decision boundary occurs for a single feature of the iris data set. I am certain i need to solve the equation P(x/SWL) = P(x/VWL) and obtain the solutions for x.I get an error for the code i tried below. The error states x is an undefined variable. Can you tell me where i am going wrong?
load fisheriris
SWL=meas(1:50,1)
VWL=meas(51:100,1)
V1 = var(SWL);
V2 = var(VWL);
M1 = mean(SWL);
M2 = mean(VWL);
P1 = (1/(sqrt(2*pi*V1))*(exp(((x-M1)^2)/(2*V1))));
P2 = (1/(sqrt(2*pi*V2))*(exp(((x-M2)^2)/(2*V2))));
solve(P1-P2);

採用された回答

Star Strider
Star Strider 2015 年 2 月 3 日
The easiest way is to use the fzero function:
P1 = @(x) (1/(sqrt(2*pi*V1))*(exp(((x-M1)^2)/(2*V1)))); % ‘P1’ As Anonymous Function
P2 = @(x) (1/(sqrt(2*pi*V2))*(exp(((x-M2)^2)/(2*V2)))); % ‘P2’ As Anonymous Function
X = fzero(@(x) P1(x)-P2(x), 1) % Create Anonymous Funciton, Solve For ‘x’
produces:
X =
3.0804
  6 件のコメント
nazneen
nazneen 2015 年 2 月 20 日
Thank you
Star Strider
Star Strider 2015 年 2 月 20 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by