필터 지우기
필터 지우기

Help with a for loop

조회 수: 2 (최근 30일)
Marc Elmeua
Marc Elmeua 2020년 9월 7일
답변: Mohammad Sami 2020년 9월 7일
Dear comunity,
I am using a COM interface to pull data from a data collection software. Problem is it pulls channel by channel and I have 80 channels per subject. So I am trying to pull it with a for loop as follows:
for i = 1:c %'c' is the number of channels
SR = h.invoke('GetPerChannelSampleRate',i); %gives sample rates for each channel
ch = h.invoke('GetChannelName',i) %gives names for each channel
x = h.invoke('ReadData', i, xmin, xmax); %gives signal of each channel
collated(i,:) = x; %collates all channels into an array
end
'collated' will nicely (but slowly) place each 'x' in consecutive rows. 'SR' is a 1x1 double and 'ch' a char.
Now I am struggling to get the loop to create a table with ch headers and SR values.
Any thoughts?
Thank you.
  댓글 수: 1
Rik
Rik 2020년 9월 7일
If you want a table, have you read the documentation for how to create a table?

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

채택된 답변

Mohammad Sami
Mohammad Sami 2020년 9월 7일
Since you have an array you can use array2table function.
In your for loop change ch to a cell array.
ch{i} = h.invoke('GetChannelName',i);
Then you can create the table with variable names in ch variable.
collated = array2table(collated,'VariableNames',ch);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by