Changeset 194 for aedes_readjcamp.m


Ignore:
Timestamp:
Feb 17, 2012, 1:10:34 PM (7 years ago)
Author:
tjniskan
Message:
  • aedes_readjcamp now correctly reads matrices from JCAMP files into cell arrays.
  • aedes_readbruker now tries to read information from acqp and method files when opening a 2dseq file.
  • aedes_readbruker now reads also visu_pars file and uses that to read the 2dseq file if reco file is not found.

M aedes_readbruker.m
M aedes_readjcamp.m
M aedes_revision.m

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aedes_readjcamp.m

    r189 r194  
    124124end
    125125
    126 % Remove string identifiers
     126% Handle strings and string lists
    127127if val(1) == '<' && val(end) == '>'
    128         val = val(2:end-1);
    129         out = val;
    130         return
    131 end
    132 
    133 % Check if the string contains numbers at all before tryin to convert to a
     128        val(val=='<')='''';
     129        val(val=='>')='''';
     130        out = eval(['{',val,'}']);
     131        if length(out) == 1
     132                out = out{1};
     133        end
     134        return
     135end
     136
     137% Handle cell matrices
     138if val(1) == '(' && val(end) == ')'
     139        nRows = length(find(val==')'));
     140       
     141        val(1) = '';
     142        val(end) = '';
     143        val(val=='(')='';
     144        val(val==')')=',';
     145        val(val=='<')='';
     146        val(val=='>')='';
     147       
     148        % Split using the commas
     149        val_split = regexp(val,',\s*','split');
     150        val_out = cell(size(val_split));
     151       
     152        % Try to convert to numbers
     153        for ii = 1:length(val_split)
     154                num = str2double(val_split{ii});
     155                if isnan(num)
     156                        val_out{ii} = val_split{ii};
     157                else
     158                        val_out{ii} = num;
     159                end
     160        end
     161       
     162        out = reshape(val_out,[],nRows).';
     163        return
     164end
     165
     166% Check if the string contains only numbers before tryin to convert to a
    134167% number. str2num uses eval command and if the string matches to a
    135168% function name strange things can happen...
    136 tmp2 = regexp(val,'.*\d.*');
    137 if isempty(tmp2)
     169tmp2 = regexp(val,'[^\d\.\seE-+]');
     170if ~isempty(tmp2)
    138171        out = val;
    139172        return
Note: See TracChangeset for help on using the changeset viewer.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008