abfadddata
Adds data to be written in an ABF file. The data is grouped as part of the last created subcase, if any.
Attention: Available only with Twin Activate commercial edition.
Syntax
R = abfadddata(fid, type, request, component, vector)
R = abfadddata(fid, type, request, component, vector, unittype, unit)
Inputs
- fid
- Integer representing the file ID.
- type
- A string containing the name of the data type.
- request
- A string containing the name of the data request.
- component
- A string containing the name of the data component.
- vector
- A vector containing the data.
- unittype
- Type of the unit (this is optional).To get valid unit types, use getunittypelist.
- unit
- Name of the unit (this is optional). Must be given if unit type is given. To get valid units, use getunitlist.
Outputs
- R
- Numerical equivalent true/false.
Example
% Example abfadddata
file = 'abfexample.abf'
fid = createabffile(file);
abfsetversion(fid,11.0);
% Create the vectors for export. These must be declared as 'global'
timevar = linspace(0, 10, 10);
x1 = [1:10];
y1 = sin(x1);
x2 = [10:10:100];
y2 = cos(x2);
% Each pair will be grouped in a subcase (this is optional)
ret = abfcreatesubcase(fid, 'subcase 1');
if(ret == false)
error('Error creating subcase 1');
end
% Adds the 1st set of vectors to the above subcase and assigns required field names
abfadddata(fid, 'type1', 'req1','comp1',x1);
abfadddata(fid, 'type1', 'req1','comp2',y1);
abfadddata(fid, 'type1', 'req2','comp1',x2);
abfadddata(fid, 'type1', 'req2','comp2',y2);
% Set a custom time vector. Even though it is not mandatory
abfadddata(fid, 'Time', 'Time', 'Time', timevar);
ret = abfclose(fid);
if(ret == false)
error('Error exporting data');
end
t = readvector(file,'subcase 1','type1', 'req1','comp2')
file = c:/work/abftest.abf
t = [Matrix] 1 x 10
0.84147 0.90930 0.14112 -0.75680 -0.95892 -0.27942 0.65699 0.98936 0.41212 -0.54402