Matlab error, what am I doing wrong?

I have written the followin code on Matlab :
class1 = [0, 0; 0, 1; 2, 2; 3, 1; 3, 2; 3, 3;];
class2 = [6, 9; 8, 9; 9, 8; 9, 9; 9, 10; 8, 11;];
mu1 = mean(class1);
mu2 = mean(class2);
sigma1 = cov(class1);
sigma2 = cov(class2);
syms x y;
g1 = -0.5*([x;y]-mu1)*inv(sigma1)*([x;y]-mu1)-log(2*pi)-0.5*log(det(sigma1));
g2 = -0.5*([x;y]-mu2)*inv(sigma2)*([x;y]-mu2)-log(2*pi)-0.5*log(det(sigma2));
g = g1 - g2;
ezplot(g, [[-1,11], [-1,11]]);
and this is the error I keep getting :
??? g1 = -0.5*([x;y]-mu1)*inv(sigma1)*([x;y]-mu1)-log(2*pi)-0.5*log(det(sigma1));
|
Error: The input character is not valid in MATLAB statements or expressions.

 採用された回答

José-Luis
José-Luis 2014 年 8 月 26 日

0 投票

The transpose character is not what you think it is:
g1 = -0.5*([x;y]-mu1')'*inv(sigma1)*([x;y]-mu1')-log(2*pi)-0.5*log(det(sigma1));

6 件のコメント

Lala
Lala 2014 年 8 月 26 日
What is it then ?
José-Luis
José-Luis 2014 年 8 月 26 日
Please copy/paste the modified line and you can see for yourself.
Lala
Lala 2014 年 8 月 26 日
Thank you José. What is the symbol I used earlier used for ?
Image Analyst
Image Analyst 2014 年 8 月 26 日
I don't think the slanted apostrophe is used for anything in MATLAB, that I'm aware of anyway.
Lala
Lala 2014 年 8 月 26 日
Ok, thank you once again, you have been very helpful.
José-Luis
José-Luis 2014 年 8 月 26 日
My pleasure. Please accept an answer if it helped you.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 8 月 26 日

コメント済み:

2014 年 8 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by