code errors at app designer

2 ビュー (過去 30 日間)
Shatha
Shatha 2022 年 12 月 12 日
回答済み: Kevin Holly 2022 年 12 月 15 日
  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 Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by