MATLAB Answers

0

Is there a way to vectorize operations such as plots (e.g. cwt()) on 2 dimensional matrices?

Asked by Seth Levine on 4 Nov 2018
I am trying to efficiently create and save plots of each row of values from a [40000 x 256] matrix samplesMatrix as an image. Each row is a frame of sensor data. The corresponding class label for each frame is stored in ActID where each row entry corresponds to class label of each frame of sensor data. The main parts of the code are shown here. The only way I have implemented it thus far is using a for loop:
for i = 1:size(samplesMatrix,1)
cwt(samplesMatrix(i,:))
t = strcat('Scalogram ', '_', num2str(actID(i)), '_', num2str(i));
saveas(gcf, fullfile(destinationFolder, t), 'png')
With the for loop this implementation ends up taking hours. Is there a way of vectorizing an operation like this? Each image is saved to a folder based on the activity id, so the destinationFolder changes as well.
Is there a more efficient way of doing this? Is there a way of vectorizing operations such as plots?

  0 Comments

Sign in to comment.

0 Answers