Change properties of more than one channel for a session-based DAQ object

조회 수: 1 (최근 30일)
C R
C R 2014년 2월 25일
답변: Shyam Sangaraju 2014년 7월 23일
Concerning the session-based DAQ control:
s = daq.createSession('ni');
s.addAnalogInputChannel('cDAQ1Mod6',[0 1 2 3],'Thermocouple');
When there are multiple channels, how to I assign similar properties. For example:
s.Channels.Thermocoupletype = 'J';
This does not work when there is more than one channel assigned on the left hand side, and only one on the right (It seems there is no overloaded function to distribute the 'J' to all channels...).
Also, and I feel like the solution, shown with 3 channels:
s.Channels(1).Thermocoupletype = 'J';
s.Channels(2).Thermocoupletype = 'J';
s.Channels(3).Thermocoupletype = 'J';
Is poor at best, and very cumbersome - if you have 15 channels and 3 properties, that is 45 lines of code!!! For loops seem like a bad idea also, thou I am sure they work.
How can I change Channel properties for multiple channels at one time?
Many fine details for session-based DAQ work are difficult to find in the help documentation. Please guide me.
Thanks for any advice.

답변 (1개)

Shyam Sangaraju
Shyam Sangaraju 2014년 7월 23일
“set” function can be used to assign similar properties to multiple channels. Following sample code demonstrates how to use “set” function:
>> s = daq.createSession('ni');
>> h = s.addAnalogInputChannel('Dev1',[0 1 2 3],'Voltage');
>> set(h,'Name','HWDigital');
Where ‘Name’ is PropertyName (in your case it could be ‘Thermocoupletype’).
HWDigitalis PropertyValue (in your case it could be ‘J’).
his vector of handles.
“set” function sets the named properties to the specified values on the object(s) identified by H. H can be a vector of handles, in which case set sets the properties' values for all the objects.

카테고리

Help CenterFile Exchange에서 Simultaneous and Synchronized Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by