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

8 次查看(过去 30 天)
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 个评论
Venkata Siva Krishna Madala
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 2018-6-19
编辑:Bob Dekraker 2018-6-19
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

请先登录,再进行评论。

回答(1 个)

cristina9
cristina9 2018-10-12
编辑:cristina9 2018-10-12
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?

类别

Help CenterFile Exchange 中查找有关 Naming Conventions 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by