i got error on running roughnessGUI

4 ビュー (過去 30 日間)
Azhan Lazit
Azhan Lazit 2020 年 4 月 20 日
回答済み: Mehmed Saad 2020 年 4 月 20 日
i get this error can somebody help?
Brace indexing is not supported for variables of this type.
Error in roughnessGUI>open_image_Callback (line 73)
image=imread(char(filename{1}));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in roughnessGUI (line 41)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)roughnessGUI('open_image_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating Menu Callback.

回答 (1 件)

Mehmed Saad
Mehmed Saad 2020 年 4 月 20 日
Error in this line
image=imread(char(filename{1}));
it looks like filename is a variable of type char or some other but not a cell. if filename is
filename = 'C\User\PPC\Downloads\Im.png';
then
filename{1}
Brace indexing is not supported for variables of this type.
because filename is a char not a cell, now convert it to cell
filename = {'C\User\PPC\Downloads\Im.png'};
then
filename{1}
ans =
'C\User\PPC\Downloads\Im.png'
To save multiple filename in variable filename
filename = {'C\User\PPC\Downloads\Im.png','C\User\PPC\Downloads\Re.png'};
Now you can use
iimage=imread(char(filename{1}));

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by