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

조회 수: 4 (최근 30일)
haryana thomas
haryana thomas 2018년 6월 8일
편집: cristina9 2018년 10월 12일
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
Venkata Siva Krishna Madala 2018년 6월 12일
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에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by