Borrar filtros
Borrar filtros

Attempt to extract field 'ThermocoupleType' from 'mxArray'.

3 visualizaciones (últimos 30 días)
haryana thomas
haryana thomas el 8 de Jun. de 2018
Editada: cristina9 el 12 de Oct. de 2018
I'm trying to write code in simulink block editor to take live input data from a thermocouple, through a DAQ system, to display the data on a scope. The thermocouple is a K type thermocouple. If I don't specify the type, I get an error message asking for the thermocouple type. When I specify K type, I get the error 'Attempt to extract field 'ThermocoupleType' from 'mxArray'.'
What should I do?
Code:
function data = Thermocouple()
coder.extrinsic('daq.createSession','addAnalogInputChannel','startForeground','T')
T = daq.createSession('ni');
ch0 = addAnalogInputChannel(T,'cDAQ9185-1D2BD3AMod2',0,'Thermocouple');
ch0.ThermocoupleType = 'k';
data = zeros(1,1000);
data = startForeground(T);
Thanks in advance!
  2 comentarios
Venkata Siva Krishna Madala
Venkata Siva Krishna Madala el 12 de Jun. de 2018
Since "addAnalogInputChannel" is extrinsic, it returns an "mxArray" object, which overrides the data type of "ch0" to be an "mxArray" as well.
In order to solve this error pre-initialize the desired fields / variables, and then assign the value to the field.
Bob Dekraker
Bob Dekraker el 19 de Jun. de 2018
Editada: Bob Dekraker el 19 de Jun. de 2018
I'm not exactly sure what to preinitialize it to. Is this what you were thinking?
function data = Thermocouple()
coder.extrinsic('daq.createSession','addAnalogInputChannel','startForeground','T')
T = daq.createSession('ni');
ch0 = addAnalogInputChannel(T,'cDAQ9185-1D2BD3AMod2',0,'Thermocouple');
ch0.ThermocoupleType = zeros(1,1)
ch0.ThermocoupleType = 'k';
data = zeros(1,1000);
data = startForeground(T);
Thanks

Iniciar sesión para comentar.

Respuestas (1)

cristina9
cristina9 el 12 de Oct. de 2018
Editada: cristina9 el 12 de Oct. de 2018
Same quesiton! I call "timedelaynet" to train a neural network on line in the simulink, and then hope to get the weight value of the neural network. I specify the type of the variable in advance, but it does not work.
coder.extrinsic('net'); net.IW{1,1}=zeros(5,4); %error message:Attempt to extract field 'IW' from 'mxArray' [net,tr]=train(net,inputs,targets,inputStates,layerStates);
What should I do?

Categorías

Más información sobre Naming Conventions en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by