store the created file in a folder in every iteration,MATLAB -


i m creating .wav file in every iteration of loop , .wav files stored in current directory working on .now want create folder in current directory , each created file should store in created folder in each iteration...

for i=1:size(seg_data(:,1))     w(i,:)=data(seg_data(i,1): seg_data(i,2));     wavwrite(w(i,:),['file_',num2str(i)]); end 

you should use mkdir create new directory (once).
should provide relative path new folder wavwrite

subfoldername = 'mysubfolder'; % example mkdir( subfoldername ); % if folder exists, warning issued ii=1:size( seg_data, 1 )     % ... stuff here     wavwrite( w(ii,:), fullfile( subfoldername, sprintf( 'file_%d', ii ) ) ); end 

note use of fullfile create path string - works windows linux paths.

ps,
best not use i variable name in matlab.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -