code errors at app designer

2 Ansichten (letzte 30 Tage)
Shatha
Shatha am 12 Dez. 2022
Beantwortet: Kevin Holly am 15 Dez. 2022
  1 Kommentar
Nikhil
Nikhil am 13 Dez. 2022
Hi Shatha, can you hover on the red part beside the scroll bar and look what error MATLAB is throwing ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Kevin Holly
Kevin Holly am 15 Dez. 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)

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by