How do I create multiple figure of cwt in for loop and save them on folder
2 次查看(过去 30 天)
显示 更早的评论
Hi everyone!
I record data from emg sensor and segment the signal. I want to convert signal in cwt figure and save them as a picture my example file contain 2560*46 (46 figures).
This is my code and file
load Data_segment.mat
%% Normalized frequency (*pi rad/sample)
frequencyLimits = [0 1];
voicesPerOctave = 8;
%% Convert to cycles/samples
frequencyLimits =frequencyLimits/2;
path = 'C:\Users\payusan\Matlab\BB\cwt\AI\Dataset_creation\CWT_creation' ;
myfolder = 'output_CH1' ;
folder = mkdir([path,filesep,myfolder]) ;
path = [path,filesep,myfolder] ;
for k = 1:length(Data_segment(end,:))
for i = 1 : length(Data_segment(:,end))
for j = 1 : length(Data_segment(end,:))
figure(j)
frequencyLimits(1) = max(frequencyLimits(1),...
cwtfreqbounds(numel(Data_sgement(:,i))));
[WT,F]= cwt(Data_segment(:,i), ...
'VoicesPerOctave',voicesPerOctave, ...
'FrequencyLimits',frequencyLimits);
pcolor(1:numel(Data_segment(:,i),log2(F),abs(WT)));
shading interp;
end
end
temp=[path,filesep,'seg_',num2str(k),'.jpg'];
saveas(figure(k),temp);
end
How do I fix this code.
4 个评论
KSSV
2022-4-8
We cannot run the code as all the variables are not given,
Unrecognized function or variable 'frequencyLimits'.
Error in Junk (line 14)
frequencyLimits(1) = max(frequencyLimits(1),...
Note that pcolor needs matrix as input. In your case it is not, so error popped out.
回答(1 个)
KSSV
2022-4-8
May be you need th add the below shown line after loading the data from mat file.
load Data_segment
Data_segment = New_data ;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!