Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Illegal use of reserved keyword "if".

50 views
Skip to first unread message

Bluemath

unread,
Aug 20, 2013, 10:20:34 AM8/20/13
to
I created several cases based on a pre-existing script. For one of those I copied the following:

if ~ERRORS,
n_cnames = n_cnames(1:size(n_cnames,1)-1, :);
sel_cond = sel_cond(1:1:numel(sel_cond)-1);
end

(it is perfectly working for other cases, but when I switch to the last one it gives the following errors 'Illegal use of the reserved keyword "if"' and 'Invalid syntax of IF. Possibly a ),} or ] are missing'

Can anybody help, please?
Regards

Steven_Lord

unread,
Aug 20, 2013, 12:18:10 PM8/20/13
to


"Bluemath " <lucian...@gmail.com> wrote in message
news:kuvtvi$h43$1...@newscl01ah.mathworks.com...
So what does "the last one" look like?

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Bluemath

unread,
Aug 20, 2013, 1:19:09 PM8/20/13
to
"Steven_Lord" <sl...@mathworks.com> wrote in message <kv04s2$iqg$1...@newscl01ah.mathworks.com>...
>
>
> "Bluemath " <lucian...@gmail.com> wrote in message
> news:kuvtvi$h43$1...@newscl01ah.mathworks.com...
> > I created several cases based on a pre-existing script. For one of those I
> > copied the following:
> >
> > if ~ERRORS, n_cnames = n_cnames(1:size(n_cnames,1)-1, :);
> > sel_cond = sel_cond(1:1:numel(sel_cond)-1);
> > end
> >
> > (it is perfectly working for other cases, but when I switch to the last
> > one it gives the following errors 'Illegal use of the reserved keyword
> > "if"' and 'Invalid syntax of IF. Possibly a ),} or ] are missing'
>
> So what does "the last one" look like?
>
> --
> Steve Lord

Hi Steve,

Thanks for offering your help. I think this is the part that creates issues:


if nargin<4
dir = '';
filestobeanalyzed = '';

%task = 'gambling';
%task = 'gonogo';
task = 'memory';


ERRORS = 1; % Include error trials in the design ('1') or not ('0').
end
RESPONSE = 0; % Include RESPONSES in the design ('1') or not ('0').

%XXXXXXXXXX END OF Session specific vartiables XXXXXXXXXXXXXXXXXXXXXXXXXXXX

% Notes.
%-------




%XXXXXXXXXX END OF Notes section XXXXXXXXXXXXXXXXXXXXXXXXXXXX

%% parameters for the excel script that writes the mean data for each
%% subject

% write_mean = 'no'; %'yes' or 'no', if 'no' the mean data are
% % not added to the total file
% meanfilename = 'test switch.xls';
% % filename were mean results are saved if
% % write_mean = 'yes'. For the swithing task
% % results are written in a txt-file, if not
% % specified here it is altered lateron
select4spm = 1; % Create new files with only a selection of
% the conditions
LogExt = '.log'; % extention that marks a log-file
%LogExt = '.xls'; % extention that marks a log-file
LogExt = filestobeanalyzed;


%% parameters to search for in the logfile, according to right of left
%% needed answer
%% if not applicable in the present task fill in 'a word that not exists in the logfile'. e.g., Cleft = str2mat ('bikini')

switch task

case 'memory'
%15. memory taks, experiment 2
%--------------------------------------------------------------------------

Ctarget = str2mat(...
'AG_E1_Low', 'AG_E1_High', 'AG_E2_Low', 'AG_E2_High', 'AG_DE_Low', 'AG_DE_High', 'AG_D_Low', 'AG_D_High', ...
'Enc_E1_Low', 'Enc_E1_High', 'Enc_E2_Low', 'Enc_E2_High', 'Enc_DE_Low', 'Enc_DE_High', 'Enc_D_Low', 'Enc_D_High', ...
'Movie');
Ctarget_ = Ctarget;
Cresponse = str2mat('hit', 'miss', 'other'); % hit, false alarm, incorrect, miss
Cresponse_ = str2mat('hit', 'miss', 'other'); % hit, false_alarm, incorrect, miss - has to be double to file with _ because spaces are not good in matlab :)

end % end of switch


case 'memory'

%--------------------------------------------------------------------------
sel_cond = {...
{'AG_E1_Low_other'},...
{'AG_E1_High_other'},...
{'AG_E2_Low_other'},...
{'AG_E2_High_other'},...
{'AG_DE_Low_other'},...
{'AG_DE_High_other'},...
{'AG_D_Low_other'},...
{'AG_D_High_other'}, ...
{'Enc_E1_Low_other'},...
{'Enc_E1_High_other'},...
{'Enc_E2_Low_other'},...
{'Enc_E2_High_other'},...
{'Enc_DE_Low_other'},...
{'Enc_DE_High_other'},...
{'Enc_D_Low_other'},...
{'Enc_D_High_other', ...
{'Movie_other'},...
{'AG_E1_Low_hit'}, ...
{'AG_E1_High_hit'}, ...
{'AG_E2_Low_hit'}, ...
{'AG_E2_High_hit'}, ...
{'AG_DE_Low_hit'}, ...
{'AG_DE_High_hit'}, ...
{'AG_D_Low_hit'}, ...
{'AG_D_High_hit'}, ...
{'Enc_E1_Low_hit'}, ...
{'Enc_E1_High_hit'}, ...
{'Enc_E2_Low_hit'}, ...
{'Enc_E2_High_hit'}, ...
{'Enc_DE_Low_hit'}, ...
{'Enc_DE_High_hit'}, ...
{'Enc_D_Low_hit'}, ...
{'Enc_D_High_hit'}, ...
{'Movie_hit'}, ...
{'AG_E1_Low_miss'}, ...
{'AG_E1_High_miss'}, ...
{'AG_E2_Low_miss'}, ...
{'AG_E2_High_miss'}, ...
{'AG_DE_Low_miss'}, ...
{'AG_DE_High_miss'}, ...
{'AG_D_Low_miss'}, ...
{'AG_D_High_miss'}, ...
{'Enc_E1_High_miss'}, ...
{'Enc_E2_Low_miss'}, ...
{'Enc_E2_High_miss'}, ...
{'Enc_DE_Low_miss'}, ...
{'Enc_DE_High_miss'}, ...
{'Enc_D_Low_miss'}, ...
{'Enc_D_High_miss'}, ...
{'Movie_miss'};


n_cnames == str2mat('AG_E1_Low', ...
'AG_E1_High', ...
'AG_E2_Low', ...
'AG_E2_High', ...
'AG_DE_Low', ...
'AG_DE_High', ...
'AG_D_Low', ...
'AG_D_High', ...
'Enc_E1_Low', ...
'Enc_E1_High', ...
'Enc_E2_Low', ...
'Enc_E2_High', ...
'Enc_DE_Low', ...
'Enc_DE_High', ...
'Enc_D_Low', ...
'Enc_D_High', ...
'Movie');

if ~ERRORS,
n_cnames = n_cnames(1:size(n_cnames,1)-1, :);
sel_cond = sel_cond([1:1:numel(sel_cond)-1]);
end

% Run the selection routine
[nme, on, dur] = lnp_selectcond4spm_select(condition_names, on, dur, rt, sel_cond, n_cnames, filenameTO, filenameCN, filenameRT);

% Save in SPM05 jobmanager compatible structure
onsetfiles{i} = Save_SPM5_Comp(nme, on, dur, dir, logfn);

The last "if" is were the problem occurs.

Hope you can see better what I did wrong.

Regards,
Lucy

Nasser M. Abbasi

unread,
Aug 20, 2013, 3:09:10 PM8/20/13
to
When you copy snippet of code from inside a function and run it on its own,
some variables used in that snippet might not have values defined for
them. When run the above snippet on its own, what values does
ERRORS have at that time?



Lauren

unread,
Jul 22, 2015, 7:02:10 PM7/22/15
to
"Bluemath" wrote in message <kuvtvi$h43$1...@newscl01ah.mathworks.com>...
Late answer, but I thought I'd post for others:

I just had the same problem. The issue was an open "[" elsewhere in the code, which is what Matlab means when it says "Possibly a ), } or ] are missing".
0 new messages