Hi. Trying to run a script that seems to have worked previously for a colleague. I get an error, but when I run it line by line it reveals the error is coming from the last line noted in the section pasted below of the script in boldface). The file it is referring to is a simple text file (Attached).
The error it produces reads in the command window as:
Error using table (line 234)
Error: File: strncmpi.m Line: 1 Column: 1
The input character is not valid in MATLAB statements or expressions."
The script used to elicit this error is:
filename = 'C:\Users\Rick\Desktop\Exp_022_ICAR_Cleaned\Advanced_Event_List_AnMan_12_16_09.txt';
delimiter = '\t';
formatSpec = '%f%q%f%q%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'ReturnOnError', false);
%% Close the text file.
fclose(fileID);
%% Create output variable
AdvancedEventListAnMan = table(dataArray{1:end-1}, 'VariableNames', {'VarName1','An1SCH','VarName3','An1SCH1'});
Any insight or tips on how I can change things to make this work?
Many thanks.

4 commentaires

Image Analyst
Image Analyst le 3 Juil 2019
It works perfectly for me in R2018b. No error at all and table is created beautifully. What version are you using?
Richard Addante
Richard Addante le 3 Juil 2019
hmm. 2017b
What shows up for
which -all strncmpi
Richard Addante
Richard Addante le 3 Juil 2019
Thanks. I upgraded to 2018b. Then tried again. Got following error. Then tried the which-all strncmpi request as noted above. Results for each are noted below, in sequence. Thank you for you helpful advice.
Error using table (line 328)
Operands to the || and && operators must be convertible to logical scalar values.
>> which -all strncmpi
C:\Users\Rick\Desktop\eeglab13_6_5b\plugins\Biosig3.3.0\biosig\maybe-missing\strncmpi.m
C:\Program Files\MATLAB\R2018b\toolbox\matlab\strfun\@opaque\strncmpi.m % opaque method
strncmpi is a built-in method % connector.internal.LoggerLevel method
strncmpi is a built-in method % connector.internal.PromiseState method
strncmpi is a built-in method % mtree.Type method
C:\Program Files\MATLAB\R2018b\toolbox\matlab\bigdata\@tall\strncmpi.m % tall method
C:\Program Files\MATLAB\R2018b\toolbox\distcomp\parallel\@codistributed\strncmpi.m % codistributed method
built-in (C:\Program Files\MATLAB\R2018b\toolbox\matlab\strfun\strncmpi) % Shadowed

Connectez-vous pour commenter.

Réponses (2)

Rik
Rik le 3 Juil 2019

0 votes

Rename your own function (C:\Users\Rick\Desktop\eeglab13_6_5b\plugins\Biosig3.3.0\biosig\maybe-missing\strncmpi.m). It is being called instead of the built-in function, which often leads to issues like this.

4 commentaires

Richard Addante
Richard Addante le 3 Juil 2019
Thanks. Rename it as what, precisely, is the recommendation? And would it have dynamic effects on other functions that may call upon it that I may not be aware of? And then were would I update the line of code that calls upon it to be apparently eliciting the original error? Thanks,
Walter Roberson
Walter Roberson le 3 Juil 2019
Use pathtool to move C:\Users\Rick\Desktop\eeglab13_6_5b\plugins\Biosig3.3.0\biosig\maybe-missing\ to the bottom (end of the path)
Rik
Rik le 3 Juil 2019
@Walter, that is probably a much better solution.
@Richard, while you're moving things, maybe it is a good idea to reconsider the place where you installed that plugin. I suspect folders on the desktop have a high risc of being renamed or deleted, which would render the functions that rely on the code inside stop working.
Guillaume
Guillaume le 3 Juil 2019
Modifié(e) : Guillaume le 3 Juil 2019
I'm sure that's not the first time I've seen a question on this forum where the problem was caused by that Biosig toolbox shadowing matlab functions. If this is the case (can't find the other post), then the toolbox is simply badly designed and users should carefuly consider if they really need it.

Connectez-vous pour commenter.

Richard Addante
Richard Addante le 5 Juil 2019

0 votes

Thanks everyone. I think it worked by running that initial problematic section of code before setting the path to the biosig toolbox, afterwhich everything continued to work. Thank you for yoru help and patience.

Catégories

En savoir plus sur Platform and License dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by