Warning: Matrix is singular to working precision.

This is my code and I keep getting the error "Warning: Matrix is singular to working precision." I am getting extremely frustrated because i looked up the problem and my code seems to be correct but i am new to this so i could be missing something. Any help would be appreciated! Thank you! :)
x=(-pi:pi/10:pi);
y=(-pi:pi/10:pi);
[X,Y]=meshgrid(x,y)
Z=(sin(sqrt(X.^2+Y.^2)))/(sqrt(X.^2+Y.^2));
mesh(X,Y,Z)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')

 採用された回答

James Tursa
James Tursa 2015 年 3 月 5 日
編集済み: James Tursa 2015 年 3 月 5 日

1 投票

Z=(sin(sqrt(X.^2+Y.^2)))./(sqrt(X.^2+Y.^2)); % changed / to ./
The ./ is element-wise division, whereas the / implies the equivalent of linear algebra matrix inversion.
doc divide
doc mrdivide

1 件のコメント

Matthew Mercado
Matthew Mercado 2015 年 3 月 5 日
Thanks man. I really appreciate it.

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

その他の回答 (1 件)

Ed Herrera
Ed Herrera 2017 年 4 月 21 日

0 投票

Many Thanks It was really useful.

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by