フィルターのクリア

"Vector must be strictly increasing or strictly decreasing with no repeated values" error

17 ビュー (過去 30 日間)
Hello,
I'm trying to use contour to represent some data, but I get this error.
Thank you in advance.
R_a=3;
N=100;
phi=linspace(0,2*pi,N);
rho= linspace(0,R_a,N);
r = randi([50 70],1,length(rho));
A=ones(length(rho)).*r;
[x_c,y_c] = pol2cart(phi,rho);
[Ro_tag, Phi_tag]=meshgrid(rho,phi);
contour(x_c,y_c,A);
  4 件のコメント
Adam Danz
Adam Danz 2020 年 8 月 31 日
編集済み: Adam Danz 2020 年 8 月 31 日
Shot in the dark,
R_a=3;
N=100;
phi=linspace(0,2*pi,N);
rho= linspace(0,R_a,N);
r = randi([50 70],1,length(rho));
A=ones(length(rho)).*r;
[Ro_tag, Phi_tag]=meshgrid(rho,phi);
[x_c,y_c] = pol2cart(Ro_tag,Phi_tag);
contour(x_c,y_c,A);
axis equal
Michael Elman
Michael Elman 2020 年 8 月 31 日
Looks a little bit weird to me, I will try the link you posted before.

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

採用された回答

Matt J
Matt J 2020 年 8 月 31 日
編集済み: Matt J 2020 年 8 月 31 日
Your meshgrid must be Cartesian:
R_a=3;
N=100;
[X,Y]=meshgrid( linspace(-R_a,+R_a, N) );
[Phi,Rho]=cart2pol(X,Y);
A= ... computaton based on Phi and Rho ...
contour(X,Y,A);
  3 件のコメント
Matt J
Matt J 2020 年 8 月 31 日
編集済み: Matt J 2020 年 8 月 31 日
Very well, then I modify my answer to,
R_a=3;
N=100;
[X,Y]=meshgrid( linspace(-R_a,+R_a, N) );
A= ... computaton based on X and Y ...
contour(X,Y,A);
The point is, A needs to be sampled on a normal Cartesian meshgrid for the purposes of doing the contour plot. You cannot, as a starting point, set up your sample locations in polar coordinates because they will not remain monotonic when transformed by pol2cart().
Michael Elman
Michael Elman 2020 年 9 月 1 日
編集済み: Michael Elman 2020 年 9 月 1 日
contour(X,Y,A);
I think, this will do the trick, thank you.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by