How do I acquire multiple datasets using readwrite?

조회 수: 7 (최근 30일)
Brianna Miranda
Brianna Miranda 2022년 3월 1일
편집: Shushant 2023년 9월 29일
I am trying to record multiple stacks of data. This is the code I have so far, but it overwrites the existing saved file when I try to record multiple stacks. How do I get this code to save each acquired source data stack into a matrix?
N = 5; % number of stacks
timeBtw = 4; % time between stacks
timeBuff = 3; % buffer time
buffer = zeros(timeBuff/dt,1);
trigger = 1.5*[s_square;s_buffer];
source = 0.5*[s;s_buffer];
for i=1:N
[data,startTime] = readwrite(ad2,[source trigger]);
pause(timeBtw)
end

답변 (1개)

Shushant
Shushant 2023년 9월 29일
편집: Shushant 2023년 9월 29일
Hi Brianna Miranda,
I understand that you are attempting to record multiple stacks of data, and to accomplish this, you are using a "for" loop. However, you have noticed that the "data" variable is being overwritten within each iteration of the loop, resulting in the undesired behavior.
To address this issue, you can modify your code by converting the variables "data" into "cellarray" and "startTime" into vectors of the appropriate size and dimensions based on your requirements.
Refer to the following documentation for more information on "cellarray"-
Additionally, ensure that you pass the correct index to the matrices "source" and "trigger" according to your specific needs.
Kindly, refer to the following code snippet as an example of how you can make these modifications:
for i=1:N
[data{i},startTime(i)] = readwrite(ad2,[source(:,i) trigger(:,i)]);
% The size of data(:,:,i) must be equal to [source(:,i) trigger(:,i)]
pause(timeBtw)
end
Refer to the following documentation for more information on indexing-
I hope this suggestions helps in solving the issue you were facing.
Thank you,
Shushant

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by