code errors at app designer
7 views (last 30 days)
Show older comments
1 Comment
Nikhil
on 13 Dec 2022
Hi Shatha, can you hover on the red part beside the scroll bar and look what error MATLAB is throwing ?
Accepted Answer
Kevin Holly
on 15 Dec 2022
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 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!