USBオシロスコープからpcに転送されてくる一定区間の時系列データの処理を並列化させたいです。
6 views (last 30 days)
Show older comments
USBオシロスコープからpcに転送されてくる一定区間の時系列データの処理を並列化させたいです。通常はオシロで測定する時間を指定して、得られた時系列データに対して、そのまま同一のファイル内で処理を実行しているのですが、オシロスコープから転送されてくる一定区間の時系列データを等間隔に分割し、処理を並列化させ、各処理で1列のベクトルAが得られるのですが、最終的にこのAを統合させたいです。parforを使って色々とチャレンジしてみたのですが、上手くいかないのでアドバイスお願いします。
0 Comments
Answers (1)
Varun
on 22 Jan 2024
こんにちは、元幹 井上さん、
私はあなたの質問に英語で回答します。
Looks like you want to parallelize the processing of time-series data within a specific interval, transferred from the oscilloscope by splitting it into equally spaced segments, parallelize the processing of each segment and obtain a vector for each process.
You can use the “parfor” loop in MATLAB to achieve the above goal. Please refer to the following example:
% Assuming you have the time-series data stored in a variable, let's call it 'data'
% Specify the number of segments to divide the data into
numSegments = 4; % Adjust this based on your requirements
% Calculate the number of data points in each segment
segmentSize = numel(data) / numSegments;
% Initialize a cell array to store the results from each segment
resultCell = cell(1, numSegments);
% Use parfor loop to process each segment in parallel
parfor i = 1:numSegments
% Calculate the start and end indices for the current segment
startIdx = round((i - 1) * segmentSize) + 1;
endIdx = round(i * segmentSize);
% Extract the current segment of data
currentSegment = data(startIdx:endIdx);
% Perform your processing on the current segment and store the result
resultCell{i} = yourProcessingFunction(currentSegment);
end
% Combine the results from all segments into a single vector
resultVector = vertcat(resultCell{:});
Make sure to replace “yourProcessingFunction” with the actual function or code that processes each segment of data.
Please refer to the following documentation to learn more about using “parfor” loop:
Hope it helps.
0 Comments
See Also
Categories
Find more on 並列 for ループ (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!