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

62 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
clc;clear;
% c is a struct
c.Date = clock;
c.Rate = 10;
%% Reading/Setting DAQ
s = daq.createSession('dt');
s.addAnalogInputChannel('DT9804(00)','0','Voltage');
s.addAnalogInputChannel('DT9804(00)','1','Voltage');
s.addAnalogInputChannel('DT9804(00)','2','Voltage');
s.addAnalogInputChannel('DT9804(00)','3','Voltage');
s.addAnalogInputChannel('DT9804(00)','4','Voltage');
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;
startBackground(s);
% Wait until session s is stopped from the UI
while s.IsRunning
pause(0.5);
end
delete(dataListener);
delete(s);
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 (1)

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
Example:
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.

Categories

Find more on Construct and Work with Object Arrays in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!