【发布时间】:2021-03-17 06:44:15
【问题描述】:
我正在尝试在 MATLAB 中使用 App Designer 制作一个简单的 GUI。我想要一个名为“Rotate 90”的按钮,每次按下它都会将图形旋转 90 度。我设法做的是只旋转一次,但是我有一个明显的问题,当再次按下时,它会再次旋转原始图片,而不是刚刚生成的新图片。
UIAXes 是我之前在其中显示图形的轴。 在回调之前我有以下属性:
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
OpenimageButton matlab.ui.control.Button
TextArea matlab.ui.control.TextArea
DropDownHistogram matlab.ui.control.DropDown
DropDownProperties matlab.ui.control.DropDown
Rotate90Button matlab.ui.control.Button
Rotate180Button matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
UIAxes_2 matlab.ui.control.UIAxes
end
properties (Access = private)
oldpath = addpath(genpath('/Libraries/')) % Load libraries
ImageFile; % Image loaded
handlehistogram;
fullname;
degrees;
end
回调函数如下:
% Button pushed function: Rotate90Button
function Rotate90ButtonPushed(app, event)
image90 = app.ImageFile;
rotated90 = imrotate(image90, 90);
imagesc(app.UIAxes, rotated90);
end
【问题讨论】:
标签: matlab user-interface button rotation