フィルターのクリア

PCOLOR command in Matlab App Designer

11 ビュー (過去 30 日間)
Michal Cerny
Michal Cerny 2022 年 1 月 2 日
コメント済み: Image Analyst 2022 年 1 月 2 日
I have achieved working and running code in Matlab, but I have problem converting it for use in the App Designer. I am mostly struggling with the syntax. For the graph I am using UIAxes in app designer.
the code:
E=[1 1 0 0 1 0;1 1 0 0 1 0;1 1 0 0 1 0;1 1 0 0 1 0;1 1 0 0 1 0;1 1 0 0 1 0;]
grid=pcolor(padarray(E,[1 1],'replicate','post'))
grid.EdgeColor=[0 0 0]
grid.LineWidth=3
colormap(jet(4))
set(gca,'ydir','reverse')
axis equal
Thank you very much for your help
Michal Cerny

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 2 日
Instead of passing the uiaxes as the first parameter, use the 'Parent' name/value pair.
grid = pcolor(padarray(E,[1 1],'replicate','post'), ...
'Parent', app.UIAxes, 'EdgeColor', [0 0 0], 'LineWidth', 3);
colormap(app.UIAxes, jet(4))
app.UIAxes.YDir = 'reverse';
axis(app.UIAxes, 'equal')
  2 件のコメント
Michal Cerny
Michal Cerny 2022 年 1 月 2 日
Error using pcolor (line 50)
Too many input arguments.
--------------------------------
Thank you for help. For some reason it still gives the error above. There is no other "pcolor" command used anywhere in the code.
--------------------------------
Image Analyst
Image Analyst 2022 年 1 月 2 日
Try this:
E = rand(5,5); % Just for demo - you should delete this line.
app.UIAxes = axes(); % Just for demo - you should delete this line.
paddedE = padarray(E,[1 1],'replicate','post')
paddedE = 6×6
0.1886 0.4694 0.1405 0.3392 0.2175 0.2175 0.8035 0.1835 0.3030 0.5094 0.1928 0.1928 0.6563 0.1289 0.4795 0.6464 0.4215 0.4215 0.6175 0.4941 0.3259 0.2673 0.0400 0.0400 0.2382 0.3621 0.1431 0.6461 0.7562 0.7562 0.2382 0.3621 0.1431 0.6461 0.7562 0.7562
hp = pcolor(paddedE, 'Parent', app.UIAxes);
hp.EdgeColor = [0 0 0];
hp.LineWidth = 3;
colormap(app.UIAxes, jet(4))
app.UIAxes.YDir = 'reverse';
axis(app.UIAxes, 'equal')

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

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by