How do I acquire multiple datasets using readwrite?

3 ビュー (過去 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 Center および File ExchangeSimultaneous and Synchronized Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by