help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error invalid concatenation of cell array with matrix


From: Wang S
Subject: Re: Error invalid concatenation of cell array with matrix
Date: Tue, 7 Jan 2014 09:12:34 +0800

Hi Syed,

The following code is not correct
ignore_dirs =";
 
It should be
ignore_dirs = '';
or you can also write as
ignore_dirs = "";
ignore_dirs = [];

You can use "copy and paste" from email to your .m file to avoid error,
for example in the email '' may look like " which may lead to an error.
 
------------------ Original ------------------
From:  "syed khalid"<address@hidden>;
Date:  Tue, Jan 7, 2014 02:01 AM
To:  "Wang S"<address@hidden>; 
Cc:  "help"<address@hidden>; 
Subject:  Re: Error invalid concatenation of cell array with matrix

 
Hello Wang
Many thanks for your patience and great responses.

The program does the following:

Recursively finds files in a directory structure
  dirName = starting directory (root)
  extension = extension of files to look for
 ignore_dirs = (optional) if there are any directory names to exclude
   (cell array of strings)



  I am getting a syntax error as in

octave:1> LIDC_process_annotations.m
error: unterminated string constant
parse error near line 45 of file /home/syedk/OCT/LIDC/find_files.m

  syntax error

>>>     ignore_dirs ="; 
                        ^

error: called from:
error:   /home/syedk/OCT/LIDC/LIDC_process_annotations.m at line 113, column 11


My code snippet is

if ~exist('ignore_dirs', 'var')
    ignore_dirs ="; 
end
ignore_dirs_full = {'.','..',ignore_dirs{:}};
  dirData  = dir('/home/syedk/PAC/DATA/XML/tcia-lidc-xml/');      %# Get the dat
a for the current directory
  dirIndex = [dirData.isdir];   %# Find the index for directories
  fileList = {dirData(~dirIndex).name}';  %# Get a list of the files





On Sun, Jan 5, 2014 at 4:08 PM, Wang S <address@hidden> wrote:
Hi Syed,

Oh, from your code:
if ~exist('ignore_dirs', 'var')
    ignore_dirs = {};
end

I guessed that the variable "ignore_dirs" was a cell (in a {}),

but this error message suggests that the variable "ignore_dirs" was a string 
(in a '' or ""), not a cell (in a {}) ?

If "ignore_dirs" was a string, possible solution may be:
if ~exist('ignore_dirs', 'var')
    ignore_dirs = '';
end

ignore_dirs_full = {'.','..',ignore_dirs};


------------------ Original ------------------
From:  "syed khalid"<address@hidden>;

Date:  Sun, Jan 5, 2014 09:02 PM
To:  "Wang S"<address@hidden>; "help"<address@hidden>;

Subject:  Re: Error invalid concatenation of cell array with matrix



Hello Wang

  I made the modification but seem to get the following error. I am also 
showing the program
octave:1> LIDC_process_annotations.m
error: sq_string cannot be indexed with {
error: evaluating argument list element number 3
error: called from:
error:   /home/syedk/OCT/LIDC/find_files.m at line 46, column 18
error:   /home/syedk/OCT/LIDC/LIDC_process_annotations.m at line 113, column 11
octave:1> quit



if ~exist('ignore_dirs', 'var')
    ignore_dirs = {};
end
ignore_dirs_full = {'.','..',ignore_dirs{:}};
  dirData  = dir('/home/syedk/PAC/DATA/XML/tcia-lidc-xml/');      %# Get the 
data for the current directory
  dirIndex = [dirData.isdir];   %# Find the index for directories
  fileList = {dirData(~dirIndex).name}';  %# Get a list of the files

  mat_ind = cellfun(@(x) strcmp(x(end-3:end), extension), fileList, 
'UniformOutput', true); % FIND XML FILES
  fileList = fileList(mat_ind); % keep only XML files

  if ~isempty(fileList)

      fileList = cellfun(@(x) fullfile(dirName,x), fileList, 'UniformOutput', 
false);  %# Prepend path to files

  end

  subDirs = {dirData(dirIndex).name};  %# Get a list of the subdirectories
  validIndex = ~ismember(subDirs, ignore_dirs_full);  %# Find index of 
subdirectories
                                               %#   that are not '.' or '..'




On Sun, Jan 5, 2014 at 1:29 AM, Wang S <address@hidden> wrote:
Hi Syed,

I'm sorry that maybe I hadn't express it clearly in the previous email.

I've just see your attachment "find_files.m". The line 46 in your file is
ignore_dirs_full = "{'.','..'},ignore_dirs(:));"

It seems that it was wrong and it maybe should be
ignore_dirs_full = {'.','..',ignore_dirs{:}};

And I think you could CC the emails to the "address@hidden" too,
so that maybe more supporters and helpers will help you in time.

Regards,
Wang S




-- 
Syed Khalid
 
CEO
 
Pacific Cloud
 
1-408-655-1096

reply via email to

[Prev in Thread] Current Thread [Next in Thread]