code errors at app designer

7 次查看(过去 30 天)
  1 个评论
Nikhil
Nikhil 2022-12-13
Hi Shatha, can you hover on the red part beside the scroll bar and look what error MATLAB is throwing ?

请先登录,再进行评论。

采纳的回答

Kevin Holly
Kevin Holly 2022-12-15
You need to make the fullname variable a property variable, so that it can be used by the different functions within the app.
properties
fullname
end
Once this is done, you can reference the variable as such:
app.fullname
However, from the looks of your code, it seems you would want to load an image and fullname would represent the entire path to the image file. In this case, I would read the image file and use a properties variable for the image matrix.
app.fullname = fullfile(filepath,filename);
app.Image.ImageSource = app.fullname; % Display on uiimage
app.ImageMatrix = imread(app.fullname); % Get image matrix
For the function imshow, you would need to specify a uiaxes in the app to display the image. You will need to make sure a uiaxes is present on your app's canvas (uifigure). Also, the image matrix needs to be the input and not a string of the file path.
function ImageClicked(app, event)
imshow(app.ImageMatrix,'Parent',app.UIAxes) % Display image matrix on uiaxes
end
For the flipped image horizontally regardless of image size:
flipp = app.ImageMatrix(:,size(app.ImageMatrix,2):-1:1)
or
flipp = flip(app.ImageMatrix,2)
to display flipped image:
imshow(flipp,'Parent',app.UIAxes)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by