Getting an error thrown everytime I try to open more than one file in a matrix at a time

% rev: 0.1b
clear;
[filename, path] = uigetfile('*.csv','Comma Seperated Values (.csv)',...
'MultiSelect', 'on');
if filename == 0
return
end
above is the code I am using to open multiple files at once in to a matrix to open later in the script, the problem is every time I open more than one file at a time i get an error:
??? Undefined function or method 'eq' for input arguments of type 'cell'.
Error in ==> csvautomation at 8
if [filename] == 0
what should I do to avoid this error? Or get around it somehow?

 採用された回答

Chirag Gupta
Chirag Gupta 2011 年 6 月 15 日
This is because when you select multiple files, filename becomes a cell array of file names.
The operator == will error on a cell aray.
(~iscell(filename) && filename == 0)
This should take care of both cases! (Note: earlier suggested isempty which will not work)

3 件のコメント

Walter Roberson
Walter Roberson 2011 年 6 月 15 日
That should be == instead of = there.
brian collette
brian collette 2011 年 6 月 15 日
this works! thanks!
Chirag Gupta
Chirag Gupta 2011 年 6 月 15 日
updated solution, Thanks Walter for catching the typo

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by