Clear Filters
Clear Filters

Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.

132 views (last 30 days)
This code is meant to read off a data stream from a creep frame and continuously save it until told to stop by attached ui. The problem is I had to move it to a new computer and reinstall everything necessary. Now I am getting a error from line 30 which states startBackground(s);
Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
here is the input code i used. a separate Ui is created where the controlling properties like time interval, radius, initial length, triaxality and displacement increment are told. along with a folder designated, and name of output file. What should happen is that once i press run, the program should start recording the data after file directory is selected. Instead as soon as file directory is selected I get the error.
here is the code
% c is a struct
c.Date = clock;
c.Rate = 10;
%% Reading/Setting DAQ
s = daq.createSession('dt');
s.Rate = c.Rate; % Background acuisition rate
% Display graphical user interface
hGui = createDataCaptureUI(s);
% Add a listener for DataAvailable events and specify the callback function
dataListener = addlistener(s, 'DataAvailable', @(src,event) dataCapture(src, event, c, hGui));
% Start continuous background data acquisition
s.IsContinuous = true;
% Wait until session s is stopped from the UI
while s.IsRunning
I looked up solutions to the error online. but they do not seem to apply.
the gui file doesn't seem to be the source of the problem
  1 Comment
Rick Zrostlik
Rick Zrostlik on 30 Sep 2022
I am getting the same error when trying to use my Data Translation 9847. However, I have ported my code from the 'Session' interface to the 'DataAcquisition' interface. My code:
>> daqlist
>> d = daq('dt')
>> d.Rate = 30000
>> addinput(d,'DT9847-3-1(00)','0','Voltage')
>> data = read(d,30000); %<--- this line causes the error for me

Sign in to comment.

Answers (3)

per isakson
per isakson on 2 Oct 2022
Edited: per isakson on 2 Oct 2022
Always include the full error message in the your question.
I don't have the data acquisition toolbox. However, the error messages says that
  • there is an empty object
  • a property assignment to that object failed
  • a subscripted assignment will work
obj = ClassA.empty, obj(1).t = 17 % subscripted assignment works
obj = 0×0 ClassA array with properties: t
obj =
ClassA with properties: t: 17
obj = ClassA.empty, obj.t = 17 % fails
obj = 0×0 ClassA array with properties: t
Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
Now it remains to find out which object is empty and why.

CM on 18 Jun 2024 at 0:45
Edited: CM on 19 Jun 2024 at 5:17
I am getting the same problem with a DT9837a. Except that it only happens on the deployed app. Here is the code:
tempChannels = s.Channels
tempProperties = properties(s)
tempMethods = methods(s)
for iProp = 1:length(tempProperties)
start(s, 'Continuous') <- error here
Error message is: Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
That is the extent of it. It does not even give the line, though that might be something to do with using diary in a deployed app.
I suspect the error is happening somewhere in the 'start' function, but no details are being provided.
I have compared the output from the working version and the buggy deployed app. It is almost identical, except for this part after vendor:
<a href="matlab:methods('daq.dt.VendorInfo')">Methods</a>, <a href="matlab:events('daq.dt.VendorInfo')">Events</a> .
Additional data acquisition vendors may be available as downloadable support packages.
<a href="matlab:daq.internal.supportPackageInstaller">Open the Support Package Installer</a> to install additional vendors.
Plus a few other minor differences - see the two attachments.
I have tried this on 2 different deployments and they have the same issue. Version info:
I am using matlab 2023b to compile an MCR installer and the mcc command to compile a separate executable.
The mcc command includes
'-a', 'C:\Users\CM\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Data Acquisition Toolbox Support Package for Data Translation Hardware'
That toolbox is installed in matlab and I have made Fausto's changes from here:
I am also installing DataAcqOMNI_V7.8.9 on the target computer.
I have also tried matlab R2023a and got the same error. I cannot use R2024a because of a different error.
If I run the executable on the computer on which it was compiled, it produces the error.

CM on 19 Jun 2024 at 6:31
Edited: CM on 19 Jun 2024 at 6:32
I have narrowed down the 'cause' of the error to the inclusion of the '-s' parameter in the call to mcc. See example code below. Any chance we can get that fixed? I need to obfuscate. There must be something in the DT drivers that doesn't like it. I tried commenting out s.ScansAvailableFcn and the callback function, but still got the error.
mcc('-m', '-s', 'test_dt.m', '-d', 'C:\test', '-a', 'C:\Users\CM\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Data Acquisition Toolbox Support Package for Data Translation Hardware');
s = daq('dt');
s.Rate = 195.3;
for iChannel = 1:4
addinput(s, 'DT9837-A(00)', num2str(iChannel-1), 'IEPE')
s.ScansAvailableFcn = @(src, ~) collect_data(src, 0);
start(s, 'Continuous')
function collect_data(src, ~)
[data, ~, ~] = read(src, src.ScansAvailableFcnCount, 'OutputFormat', 'Matrix');


Find more on Environment and Settings in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!