フィルターのクリア

how to update image preview axis when listbox gets updated?

2 ビュー (過去 30 日間)
hush puppy
hush puppy 2015 年 5 月 25 日
コメント済み: hush puppy 2015 年 5 月 25 日
I have a matlab gui listbox (listbox1) that shows my images file name and another axis (images) to show image preview when user clicks on the file name in my listbox. I've created a button 'refresh' to update my listbox values. I managed to update my listbox but my axis is not updating. How do I update this axis as well?
function refreshListboxButton_Callback:
files = dir(fullfile(pwd,'*.jpg'));
handles.images = cell(1, numel(files));
for x = 1 : numel(files)
handles.images{x} = imread(fullfile(pwd,files(x).name));
imshow(handles.images{x});
end
set(handles.listbox1,'string',{files.name});
drawnow();

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 25 日
You need to tell imshow() which axes to draw the image on, unless you only have one axes.
You are updating the content of the handles structure, so you need to consider whether you need to use guidata() to update the master copy of the handles structure. Where is your code getting the handles structure from? You are not passing in the handles structure so handles.images{x} could be creating a new handles structure, but you assume that handles.listbox1 exists. Your code cannot be getting handles by way of shared variable, as shared variables only work with static workspaces and static workspaces require that there be an "end" matching the "function" line but you do not have that "end".
  1 件のコメント
hush puppy
hush puppy 2015 年 5 月 25 日
Thank you! I forgot my guidata() code..

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by