How to save the figure of signals in a new directory?

4 ビュー (過去 30 日間)
Amir tb
Amir tb 2020 年 6 月 19 日
編集済み: Adam Danz 2020 年 6 月 22 日
Dear firends, I'm new in Matlab coding. This is a code my teacher sent to me. It's about reading 5 .wav sounds with different lengths. The purpose is dividing each sound samples by 2000 sample for each and then figure it and process each figure seperately. For example for a sound with a length of 70000, it devides the sound into 35, 2000 samples which give us 35 seperate figures for each 2000 sample.
My question is how can I change the code such that having saved figure of each sample seperately in a new directory?
clc
clear all
close all
normrate=255;
numsamp=2000;
signal={};
image={};
zero=zeros(normrate,numsamp);
files = dir(fullfile('C:\Users\Amir\Desktop\Articles\PCG classification\matlab code\mamadreza\*.wav'));
for i=1:length(files)
X=audioread(files(i).name);
for k=1:length(X)/numsamp
Aug(:,k)=X((k-1)*numsamp+1:k*numsamp);
normalize=(Aug(:,k)-min(Aug(:,k)))*normrate/(max(Aug(:,k))-min(Aug(:,k)));
imshow(uint8(zero))
hold on
plot(normalize, 'w', 'LineWidth', 2)
f=getframe(gcf);
new=im2bw(f.cdata);
[t,r]=find(new==0);
final(:,:,k)=new(min(t):max(t), min(r):max(r));
close
end
signal{i}=Aug;
image{i}=final;
clear Aug
end

回答 (1 件)

Adam Danz
Adam Danz 2020 年 6 月 20 日
編集済み: Adam Danz 2020 年 6 月 22 日
To create a directory, mkdir parentFolder folderName.
To save a figure, see savefig(filename).
Demo: (also uses fullfile)
parentDirectory = 'C:\Users\me\Documents\MATLAB';
subDirectory = 'NewDirectoryName';
figureName = 'myFigure.fig';
d = mkdir(parentDirectory, subDirectory);
savefig(fullfile(parentDirectory, subDirectory, figureName))
  1 件のコメント
Fego Etese
Fego Etese 2020 年 6 月 21 日
Hello Adam Danz, sorry to contact you like this, but its really an emergency, please I need your help with this question
I will be grateful if you can help me out, thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by