MATLAB Answers

0

Why does the function call "function [hdr, record] = edfReadOddur( 'tinnaprim​e.edf',var​argin )" give an error?

Asked by Oddur Bjarnason on 25 Jul 2017
Latest activity Commented on by Oddur Bjarnason on 26 Jul 2017
This is the error message:
Error: File: edfReadOddur.m Line: 1 Column: 40 Unexpected MATLAB expression.

  0 Comments

Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 25 Jul 2017
 Accepted Answer

Oddur - if your function signature (the first line in edfReadOddur.m) is written as
function [hdr, record] = edfReadOddur( 'tinnaprime.edf',varargin )
then the problem is that you are trying to set the first parameter of your function as a string rather than as an input parameter/variable. Your signature should be defined as
function [hdr, record] = edfReadOddur( filename, varargin)
and you would call the above (from the command line or another piece of code) and pass in 'tinnaprime.edf' to populate/set the filename parameter
>> edfReadOddur('tinnaprime.edf')
See Function Basics for more details.

  3 Comments

Dear Geoff,
I have been trying to get edfRead by Brett Shoelson to work with my Matlab - without success. His function call is
function [hdr, record] = edfRead('tinnaprime.edf', varargin)
he insists on the single quotes but this gives me the following error message:
Error: File: edfread.m Line: 1 Column: 34 Unexpected MATLAB expression.
A tried to write to Brett a while ago but he has not answered me as yet.
I have followed your suggestions with:
function [hdr, record] = edfRead( tinna, varargin)
and command
edfRead('tinnaprime.edf')'
But I get the error message
"Error using edfRead (line 126) No such file or directory"
The lines are:
[fid,msg] = fopen(tinna,'r'); if fid == -1 error(msg) end
The file does exist and is in the Matlab path.
Can you help me?
Oddur - from edfRead at FEX, the function signature is
function [hdr, record] = edfread(fname, varargin)
so it isn't clear to me why you think that it should be
function [hdr, record] = edfRead('tinnaprime.edf', varargin)
You would call this function as
[hdr, record] = edfRead('tinnaprime.edf)
(perhaps passing more input variables as described along with this FEX submission.
As for the error, No such file or directory, try passing the full path and file name as the input parameter to edfRead.
Again I tried to take your suggestions into account. I used the following function signature:
function [hdr, record] = edfReadUntilDone(tinna, varargin)
I called the function with:
edfReadUntilDone('C:\Users\Oddur\Documents\Emotiv Files\Tinna\tinnaprime.edf')
I got the following answer:
ans =
struct with fields:
ver: 0
patientID: 'tinna '
recordID: '2 '
startdate: '01.05.16'
starttime: '20.18.56'
bytes: 10496
records: 636
duration: 1
ns: 40
label: {1×40 cell}
transducer: {1×40 cell}
units: {1×40 cell}
physicalMin: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
physicalMax: [1×40 double]
digitalMin: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
digitalMax: [1×40 double]
prefilter: {1×40 cell}
samples: [1×40 double]
frequency: [1×40 double]
From this I gather that the file has been loaded. I do unfortunately not get any data records.
The original question that I posed has now been answered so I shall accept your answer. The rest of the problems I have with the function I shall take up with Brett.
Thank you.
Oddur

Sign in to comment.