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

2 Ansichten (letzte 30 Tage)
haryana thomas
haryana thomas am 8 Jun. 2018
Bearbeitet: cristina9 am 12 Okt. 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 Kommentare
Venkata Siva Krishna Madala
Venkata Siva Krishna Madala am 12 Jun. 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 am 19 Jun. 2018
Bearbeitet: Bob Dekraker am 19 Jun. 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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

cristina9
cristina9 am 12 Okt. 2018
Bearbeitet: cristina9 am 12 Okt. 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?

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by