Borrar filtros
Borrar filtros

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

145 visualizaciones (últimos 30 días)
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 comentario
Rick Zrostlik
Rick Zrostlik el 30 de Sept. de 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

Iniciar sesión para comentar.

Respuestas (3)

per isakson
per isakson el 2 de Oct. de 2022
Editada: per isakson el 2 de Oct. de 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.

CM
CM el 18 de Jun. de 2024
Editada: CM el 19 de Jun. de 2024
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)
disp(tempProperties{iProp})
disp(s.(tempProperties{iProp}))
end
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:
https://au.mathworks.com/matlabcentral/answers/1693530-error-when-trying-to-start-acquisition-from-data-translation-device
I am also installing DataAcqOMNI_V7.8.9 on the target computer.
Update:
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
CM el 19 de Jun. de 2024
Editada: CM el 19 de Jun. de 2024
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');
test_dt.m:
s = daq('dt');
s.Rate = 195.3;
for iChannel = 1:4
addinput(s, 'DT9837-A(00)', num2str(iChannel-1), 'IEPE')
end
s.ScansAvailableFcn = @(src, ~) collect_data(src, 0);
start(s, 'Continuous')
pause(5)
stop(s);
function collect_data(src, ~)
[data, ~, ~] = read(src, src.ScansAvailableFcnCount, 'OutputFormat', 'Matrix');
disp(num2str(sum(data)))
end
  2 comentarios
Helen Zhu
Helen Zhu el 28 de Jun. de 2024 a las 18:35
Hi CM,
Have you edited matlabroot/toolbox/compiler/advanced_package_supported_files.xml. file? What's in it?
CM
CM el 28 de Jun. de 2024 a las 22:09
I have not edited it. Date modified on it is 11/8/2022 0550. Contents are:
<?xml version="1.0" encoding="UTF-8"?>
<list>
<extension>mlapp</extension>
<extension>mlx</extension>
<extension>sfx</extension>
<extension>mat</extension>
</list>

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by