フィルターのクリア

how can i compare 3 different columns of an Excel sheet with contourf plot in Matlab GUI

2 ビュー (過去 30 日間)
Hello all, nowadays i am making a GUI through matlab designer to compare different parameters, i have to compare 3 different columns of Excel sheet with contourf plot. And I am getting error of 'Error using contourf (line 57) Z must be at least a 2x2 matrix.'
Thank you all in advance, please help me out, i am stucked with my task.
here is my code:
Parameter = readmatrix('GUI1.xlsx');
Parameter1 = Parameter(51*1);
Parameter2 = Parameter(51*2);
Parameter3 = Parameter(51*3);
Parameter4 = Parameter(51*4);
if (strcmp(app.XAchseParameterDropDown.Value,'DE'))
X = Parameter1;
elseif (strcmp(app.XAchseParameterDropDown.Value,'DI'))
X = Parameter2;
elseif (strcmp(app.XAchseParameterDropDown.Value,'DrE'))
X = Parameter3;
else
X = Parameter4;
end
if (strcmp(app.YAchseParameterDropDown.Value,'DE'))
Y = Parameter1;
elseif (strcmp(app.YAchseParameterDropDown.Value,'DI'))
Y = Parameter2;
elseif (strcmp(app.YAchseParameterDropDown.Value,'DrE'))
Y = Parameter3;
else
Y = Parameter4;
end
if (strcmp(app.ZAchseParameterDropDown.Value,'DE'))
Z = Parameter1;
elseif (strcmp(app.ZAchseParameterDropDown.Value,'DI'))
Z = Parameter2;
elseif (strcmp(app.ZAchseParameterDropDown.Value,'DrE'))
Z = Parameter3;
else
Z = Parameter4;
end
contourf(app.UIAxes,X,Y,Z)
  1 件のコメント
Voss
Voss 2021 年 12 月 22 日
Can you attach the relevant Excel file (which is called 'GUI1.xlsx' in this code)?

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 12 月 24 日
編集済み: Cris LaPierre 2021 年 12 月 24 日
A contour plot is created from a matrix (Z data; see here). You must be giving it a vector, causing the error message you see.
You can learn more and see examples in the contourf documentation page.
% Works
x = -2:0.2:2;
y = -2:0.2:3;
[X,Y] = meshgrid(x,y);
Z = X.*exp(-X.^2-Y.^2);
contourf(X,Y,Z,'ShowText','on')
% recreates the error you are seeing
x = -2:0.2:2;
y = -2:0.2:3;
[X,Y] = meshgrid(x,y);
Z = X.*exp(-X.^2-Y.^2);
contourf(X,Y,Z(:),'ShowText','on')
Error using contourf (line 57)
Z must be at least a 2x2 matrix.
How you convert your column data to a matrix is going to depend on your data. It's very difficult to answer that question withough more information.
  2 件のコメント
Darshil Pragneshbhai Trivedi
Darshil Pragneshbhai Trivedi 2022 年 1 月 12 日
so i have a 4 colums and 51rows in a datasheet in excell. which 4 colums i have to compare with each other.
Cris LaPierre
Cris LaPierre 2022 年 1 月 12 日
編集済み: Cris LaPierre 2022 年 1 月 12 日
I think you'd have to tell us that. I'm not sure how we would know.
Generally speaking, your X and Y values will be inputs (independent variables) and Z will be your output or response (dependent variable).

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

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by