Conversion to cellstr from logical is not possible.

2 visualizaciones (últimos 30 días)
Stelios Fanourakis
Stelios Fanourakis el 25 de Mayo de 2018
Editada: Ameer Hamza el 25 de Mayo de 2018
Please, help on this.
axes(handles.axes1);
[fileName, pathName] = imgetfile();
if ischar(fileName); fileName = {fileName}; end
if ischar(pathName); pathName = {pathName}; end
cellstr(fileName);
cellstr(pathName);
filenames = fullfile(pathName, fileName);
I get the above error at cellstr(pathName) line.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 25 de Mayo de 2018
Editada: Ameer Hamza el 25 de Mayo de 2018
imgetfile() does not return the pathname, instead, it returns the full file address in the first output argument. The second argument in the output pathName is not a char variable but a boolean variable. Therefore it gives the error that cannot convert from logical to cellstr. You can simply use it like this
[fileName, isCancelled] = imgetfile();
if ~isCancelled % it will not run if use press cancel button instead if choosing an image.
filenames = fileName;
% continue your code
end

Más respuestas (0)

Categorías

Más información sobre Cell Arrays 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