code errors at app designer

4 visualizaciones (últimos 30 días)
Shatha
Shatha el 12 de Dic. de 2022
Respondida: Kevin Holly el 15 de Dic. de 2022
  1 comentario
Nikhil
Nikhil el 13 de Dic. de 2022
Hi Shatha, can you hover on the red part beside the scroll bar and look what error MATLAB is throwing ?

Iniciar sesión para comentar.

Respuesta aceptada

Kevin Holly
Kevin Holly el 15 de Dic. de 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)

Más respuestas (0)

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by