i am trying to get emg and force data simultaneously using parallel computing tool box but i am unable to read the data???

조회 수: 1 (최근 30일)
i am using the below code
if matlabpool('size') == 0
matlabpool open local 2
data1=zeros([122880,2]);
data2=zeros([37000,1]);
spmd
switch labindex
case 1
s = daq.createSession('ni');
s.addAnalogInputChannel('cDAQ2Mod1', 0, 'Voltage');
s.addAnalogInputChannel('cDAQ2Mod1', 1, 'Voltage');
s.Rate = 2048
s.DurationInSeconds = 60;
labBarrier
[data1,time] = s.startForeground;
case 2
delete(instrfindall);
s = serial ( 'COM5', 'BaudRate', 115200);
set(s, 'Timeout',60);
s.InputBufferSize =37000;
labBarrier
fopen(s);
data2=fread(s);
end
end
end
matlabpool close
my workspace is containing data in composite form
data1 composite
data2 composite
is there any way to solve this problem???
  댓글 수: 5
avinash pabbireddy
avinash pabbireddy 2013년 12월 2일
Error using Composite/subsref (line 48) An invalid indexing request was made
Error in sync (line 44) E=data1(:);
Caused by: Error using Composite/subsref>iCheckValuesExist (line 86) The Composite has no value on the following lab(s): 2 .

댓글을 달려면 로그인하십시오.

채택된 답변

Edric Ellis
Edric Ellis 2013년 12월 4일
The data contained within a Composite is retained on the workers. Therefore if you close the pool, the data goes away. So, you simply need to avoid closing the pool until you've got the data from the workers. One way to do this would be:
data1 = data1(:);
data2 = data2(:);
matlabpool close
Or, you could simply leave the matlabpool open.
  댓글 수: 7
Walter Roberson
Walter Roberson 2013년 12월 7일
Assign each variable on each of the labs, even it is just assigning [] to it.
data1 = s.startForeground;
data2 = [];
...
avinash pabbireddy
avinash pabbireddy 2013년 12월 7일
i am able to get data using data1=data1{:,1}; data2=data2{:,2}; thank you @walter roberson @edric ellis

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by