Difference between revisions of "MATLABUnicodePath"

From WikiMEG
Jump to: navigation, search
(Created page with "Are your plumbing skills a bit rusty? Do you want to improve your plumbing? This is the proper article for you, now that you have made the decision to learn more. Read on to f...")
 
(Created page with " Sometimes odd characters or characters with accents prevent MATLAB from opening a file, even if you copy the filename directly from Windows explorer: "04%10%08@1443" We c...")
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
Are your plumbing skills a bit rusty? Do you want to improve your plumbing? This is the proper article for you, now that you have made the decision to learn more. Read on to find out how to make your plumbing system more efficient and functional.<br><br>If your pipes are so noisy that they sound like squeaking or hammering, you can easily solve this problem. Anchor any pipes that are exposed. If the pipes are in the walls, floors or ceiling, you may want to call a professional to come and help complete the project.<br><br>To eliminate the possibility of having frozen pipes, maintain a constant temperature in your home above freezing, and be certain to adequately insulate those pipes that are out in the weather. The pipes will be able to freeze if the temperature surrounding the pipes drops below freezing. It can take a while for the pipes to thaw, which means you will not be able to run water for quite some time. The other option is the pipes may burst, which would result in significant repair costs and a mess to clean up.<br><br>Do not give a plumber the entire payment for a job until the whole job is completed. Some plumbers may require a deposit, but don't fork over all the dough until the job is completed to spec. It will make you feel better knowing that your problem has been solved before parting with a large sum of money.<br><br>Do not attempt fixing your garbage disposal with bare hands. Garbage disposals are not healthy places for hands to be, even if they are not running. Go online and search for sketch of your disposal, or a troubleshooter.<br><br>Try to have all your plumbing repairs done at once. You might want to call every time you need a tiny issue fixed with your plumbing, but if you know the system is bad, if you just call once, you can start saving for the major repair before you call. You can save money by only paying a single service call fee instead of ending up with multiple hours being billed from multiple visits.<br><br>Keep a strainer over every drain in your house to prevent stray debris from clogging your pipes. Clean the kitchen sink strainer any time something collects in it. Keep the bathroom drains cleaned out too.<br><br>If you have multiple plumbing problems, schedule all of them to be fixed together. It might be tempting to call up a plumber every time you have a small problem, but if you will save all the plumbing issues for one time, it can be helpful. It will allow you save the money for the repairs. You can save money by only paying a single service call fee instead of ending up with multiple hours being billed from multiple visits.<br><br>If you notice water draining into your dishwater, check your kitchen sink. The hose might not be installed properly. The hose from your sink to your dishwasher needs to go upward before going back down so that there is no mixing between fixtures.<br><br>If you are having trouble removing a clean-out plug, there are two ways to do it. You can loosen the fitting with a hammer and a chisel. The only other option is to chisel right through the clean out plug.<br><br>You must know what to do in the face of an emergency before it ever happens. If you liked this post and you would like to obtain even more facts regarding plumbing tips - [http://Plumbingservicemasters.com/ Learn Additional], kindly visit our own web-site. Additionally, performing a bit of routine maintenance easily keeps problems from cropping up when you least expect them. Take the tips you've read here and implement them into your plumbing strategy, preparing you to keep your plumbing in great shape and deal with any problems as they arise.
+
 
 +
Sometimes odd characters or characters with accents prevent MATLAB from opening a file, even if you copy the filename directly from Windows explorer: "04%10%08@1443"
 +
 
 +
We can use a short function to retrieve a list of all files in a certain folder:
 +
 
 +
<syntaxhighlight lang="matlab">
 +
function contents = dir2(path, filter, ignore_dot)
 +
%
 +
% dir2 list contents on path recursively, using java.io.File, so
 +
% weird characters are converted correctly to MATLAB usuable
 +
% path names.
 +
%
 +
% filter - string, expression used to filter file names
 +
% ignore_dot - ignore files and folders beginning with .
 +
%
 +
% mw 10 11 2014 - creation
 +
 
 +
if nargin < 2, filter = '.*'; end
 +
if nargin < 3, ignore_dot = 1; end
 +
 
 +
f = java.io.File(path);
 +
fs = f.listFiles();
 +
contents = {};
 +
for i=1:length(fs)
 +
    fname = fs(i).getName().toCharArray()';
 +
    abspath =  fs(i).getCanonicalPath().toCharArray()';
 +
    if ignore_dot && fname(1) == '.'
 +
        continue
 +
    end
 +
    if fs(i).isDirectory()
 +
        subcontents = dir2(abspath, filter, ignore_dot);
 +
        contents = {contents{:} subcontents{:}};
 +
    end
 +
    match = regexp(fname, filter, 'ONCE');
 +
    if match
 +
        contents = {contents{:} abspath};
 +
    end
 +
end
 +
</syntaxhighlight>
 +
 
 +
The resulting list of files can be filtered with a [http://www.mathworks.fr/help/matlab/ref/regexp.html regular expression], so that you have exactly the files you're looking for:
 +
 
 +
<syntaxhighlight lang="matlab">
 +
>> path = 'Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr';
 +
>> re = 'c,rf.*Hz$';
 +
>> fs = dir2(path, re);
 +
</syntaxhighlight>
 +
 
 +
Here, the regex says find filenames starting with "c,rf", then any character, then "Hz" then end of line "$". We can check the results:
 +
 
 +
<syntaxhighlight lang="matlab">
 +
>> for i=1:length(fs), fprintf('%s\n', fs{i}); end
 +
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\1\c,rfhp1.0Hz
 +
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\2\c,rfhp1.0Hz
 +
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\3\c,rfhp1.0Hz
 +
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\4\c,rfhp1.0Hz
 +
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\5\c,rfhp1.0Hz
 +
</syntaxhighlight>

Latest revision as of 11:17, 10 November 2014

Sometimes odd characters or characters with accents prevent MATLAB from opening a file, even if you copy the filename directly from Windows explorer: "04%10%08@1443"

We can use a short function to retrieve a list of all files in a certain folder:

function contents = dir2(path, filter, ignore_dot)
%
% dir2 list contents on path recursively, using java.io.File, so 
% weird characters are converted correctly to MATLAB usuable 
% path names.
%
% filter - string, expression used to filter file names
% ignore_dot - ignore files and folders beginning with .
%
% mw 10 11 2014 - creation
 
if nargin < 2, filter = '.*'; end
if nargin < 3, ignore_dot = 1; end
 
f = java.io.File(path);
fs = f.listFiles();
contents = {};
for i=1:length(fs)
    fname = fs(i).getName().toCharArray()';
    abspath =  fs(i).getCanonicalPath().toCharArray()';
    if ignore_dot && fname(1) == '.'
        continue
    end
    if fs(i).isDirectory()
        subcontents = dir2(abspath, filter, ignore_dot);
        contents = {contents{:} subcontents{:}};
    end
    match = regexp(fname, filter, 'ONCE');
    if match
        contents = {contents{:} abspath};
    end
end

The resulting list of files can be filtered with a regular expression, so that you have exactly the files you're looking for:

>> path = 'Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr';
>> re = 'c,rf.*Hz$';
>> fs = dir2(path, re);

Here, the regex says find filenames starting with "c,rf", then any character, then "Hz" then end of line "$". We can check the results:

>> for i=1:length(fs), fprintf('%s\n', fs{i}); end
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\1\c,rfhp1.0Hz
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\2\c,rfhp1.0Hz
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\3\c,rfhp1.0Hz
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\4\c,rfhp1.0Hz
Y:\MEG\DATA\Protocoles_epilepsie\epil\epil_003\cont3mtr\03%11%08@1035\5\c,rfhp1.0Hz