Matlab: read all wave in a folder [closed] - matlab

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I want to read all wave files in a folder in Matlab. I use this code to open theses files:
Files=dir('path folder.wav');
for k=1:length(Files)
FileNames=Files(k).name;
[s,fs]=wavread(FileNames);
end
but this code doesn't work, wave files do not open. Why? Can you help me?

The dir() command returns only file names - not the full path.
So, possible you just need to restore full path:
dirMask = 'path folder.wav';
wavRoot = fileparts(dirMask);
Files=dir(dirMask);
for k=1:length(Files)
FileNames = fullfile(wavRoot, Files(k).name);
[s,fs] = wavread(FileNames);
end

Related

Find and replace multiple string in MATLAB [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a1 in the following form in MATLAB.
a1{1,1} = {'x1','x2','x3'}
a1{1,2} = {'x1','x2','x3','x4'}
a1{1,3} = {'x4'}
I need to replace
'x1' with 'Text1'
'x2' with 'Text2'
'x3' with 'Text3'
'x4' with 'Text4'
I have tried a couple of things with no success and I am a bit lost, does anyone have any ideas.
Thanks
Regular Expressions might be a way to go with this
a1{1,1} = {'x1','x2','x3','x4'};
a1{1,1} = regexprep(a1{1,1},'x([0-9])','text$1');
Will result in a1{1,1} containing
{'text1'} {'text2'} {'text3'} {'text4'}
This will work for any single digit numerical value (0-9) that is prefixed with the letter x.

How to handle the bug in Maple latex command? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
In Windows 7, I need to use Maple to export the Tex code into a text file.
In Command-line Maple, I type latex(LambertW(x), "C:/Users/Bravo/Desktop/out.txt"); to do this, but the result is:
{\rm W} \left(x\right)
That is not right, why does it happen ? Is there any method to solve this problem ?
Yeah, that is a bug in Maple. You can try latex(subs(LambertW=lambertW,erf=Erf,arctanh=Artanh,LambertW(x)));
Reference: http://www.mapleprimes.com/questions/201975-Maple-Error-Using-Latex-Command-How-To-Resolve#comment207767

Could you please tell me what this line do: sed 's/^.*-svn\([0-9]*\).*$/\1/' [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Could you please tell me what this line do of sed
the expression is on the title
Thank you
Best regards
It replaces everything on the line with the number immediately following "-svn".
eg.:
blahblabhlabhlabhalbh-svn12345blahblhablhab
is replaced by:
12345
It's matching a string of [anything]-svn[numbers][anything], and replacing the line with the [numbers].
For example:
asda-svn123123bebeb
Gets replaced with
123123

How to keep a specific set of characters from a string using regular expression in PERL [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have this string
$eq= "ew';##rfhnbgsu.,/><hdjsdedokk";
By Perl I want to extract just the characters w, h, n, s, and f from the string.
The output should be like this
whhfnss
Could you help me?
say $s =~ /[whnsf]/g;

How to use the matlab function tar? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am now want to compress a file name File1.txt which is in the current folder. When I try to use the function tar like:
tar('File1.tgz','File1.txt');
Some error happen.
Undefined variable "File1" or function "File1.tgz".
Error in tar (line 1)
tar(File1.tgz,'File1.txt');
Is it any incorrect part of this?
You forgot to put ''.
Try:
tar('File1.tgz','File1.txt');
In my MatlabR2013a it works without problems.
Matlab example:
%Tar all files in the current directory to the file backup.tgz
tar('backup.tgz','.');