フィルターのクリア

contour plot problem Z must be at least a 2x2 matrix

33 ビュー (過去 30 日間)
Jialin Men
Jialin Men 2024 年 7 月 25 日 16:18
コメント済み: Star Strider 2024 年 7 月 25 日 21:25
Hallo everyone,
i have a problem to make the contour plot, it always shows Z must be at least a 2x2 matrix. i have try my best to solve, but it still not work, could you please to help me? The code is as follows.
x=[80;100;90;90;90]
x = 5x1
80 100 90 90 90
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
y=[4;4;2;6;4]
y = 5x1
4 4 2 6 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[X,Y] = meshgrid(x,y)
X = 5x5
80 100 90 90 90 80 100 90 90 90 80 100 90 90 90 80 100 90 90 90 80 100 90 90 90
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Y = 5x5
4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 6 6 6 6 6 4 4 4 4 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Polly 11 f(x,y)=p00+p10*x+p01*y
f1=1.7419-0.0006*x+0.0132*y
f1 = 5x1
1.7467 1.7347 1.7143 1.7671 1.7407
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
contour(X,Y,f1)
Error using contour (line 48)
Z must be at least a 2x2 matrix.
Thanks and best regards
JL

採用された回答

Star Strider
Star Strider 2024 年 7 月 25 日 16:34
Anotther option, using the scatteredInterpolant function —
x=[80;100;90;90;90]
x = 5x1
80 100 90 90 90
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
y=[4;4;2;6;4]
y = 5x1
4 4 2 6 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[X,Y] = meshgrid(x,y);
X = 5x5
80 100 90 90 90 80 100 90 90 90 80 100 90 90 90 80 100 90 90 90 80 100 90 90 90
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Y = 5x5
4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 6 6 6 6 6 4 4 4 4 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Polly 11 f(x,y)=p00+p10*x+p01*y
f1=1.7419-0.0006*x+0.0132*y
f1 = 5x1
1.7467 1.7347 1.7143 1.7671 1.7407
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Fz = scatteredInterpolant(x, y, f1)
Fz =
scatteredInterpolant with properties: Points: [5x2 double] Values: [5x1 double] Method: 'linear' ExtrapolationMethod: 'linear'
F1 = Fz(X,Y)
F1 = 5x5
1.7467 1.7347 1.7407 1.7407 1.7407 1.7467 1.7347 1.7407 1.7407 1.7407 1.7203 1.7083 1.7143 1.7143 1.7143 1.7731 1.7611 1.7671 1.7671 1.7671 1.7467 1.7347 1.7407 1.7407 1.7407
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
contour(X,Y,F1)
.
  4 件のコメント
Jialin Men
Jialin Men 2024 年 7 月 25 日 20:36
Hallo Star,
That is so kind of you. It helps me really a lot. :)
Actually what I want is to see How f1 changes with x and y, or how it distributed with different x and y by contour plot, i thought the contour plot will be like the pictures i sent it you, however it is not.
Thanks so much again for your help. That is really important to me. If i have questions i may contact to you again.
Best regards
JL
Star Strider
Star Strider 2024 年 7 月 25 日 21:25
As always, my pleasure!
I will gladly help you with any further questions.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 7 月 25 日 16:27
x=[80;100;90;90;90];
y=[4;4;2;6;4];
[X,Y] = meshgrid(x,y);
% Polly 11 f(x,y)=p00+p10*x+p01*y
f1=1.7419-0.0006*X+0.0132*Y;
contour(X,Y,f1)
  4 件のコメント
Walter Roberson
Walter Roberson 2024 年 7 月 25 日 16:57
Your plot is similar to what you would get if you used surfc
Jialin Men
Jialin Men 2024 年 7 月 25 日 20:39
Hallo Walter,
Thank you so much.
I should be have been more careful. i will use the surfc to check.
Thanks again.
JL

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by