Difference between revisions of "MATLABUnicodePath"

From WikiMEG
Jump to: navigation, search
m
(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...")
 
Line 1: Line 1:
Your home can be ruined by a bad plumbing problem. Use the tips offered in this article to help you fix your plumbing issues.<br><br>If your pipes are so noisy that they sound like squeaking or hammering, you can easily solve this problem. You will need to anchor any exposed pipes. Get a professional to anchor any hidden pipes if you do not wish to do some work in your floors or walls by yourself.<br><br>You need to avoid using any kind of tablet or odor remover in your toilet if at all possible. These may deodorize, but they can seriously damage the rubber pieces in the toilet, causing poor functionality or even complete breakdown of the fixture.<br><br>If the water in your toilet is low along with the toilet being clogged, pour some extra water in the bowl to make the plunger effective again. Once the water level gets low again, repeat the process.<br><br>Check floors around toilets for softness, so you can tell if you have any floor damage. Straddle the toilet, so you can rock from one leg to another to determine whether there's weakness in the floor. As with many problems, early detection can save you a lot of money.<br><br>Check to make sure that overflow holes are not clogged up. The overflow holes are there to make sure the sink doesn't overfill, which can become a problem if they are blocked. The overflow holes should be cleaned out regularly; do this when you are making your regular checks for other issues that necessitate fixing.<br><br>Save money by getting better shower heads. Most of our hot water is used in the shower. Water-conserving shower heads are relatively affordable, but using them can save you a great deal of money within a single year.<br><br>Do special checks on your sink overflow holes to ensure they are not becoming clogged. These holes come into use if the skin overflows. Things can get problematic if they are clogged. If you liked this posting and you would like to receive far more info regarding Real Flame Fires Melbourne ([http://Osteo.u-prod.org/36551/pipe-dreams-and-plumbing-tricks-for-your-water click through the following website page]) kindly stop by the web site. The overflow holes should be cleaned out regularly; do this when you are making your regular checks for other issues that necessitate fixing.<br><br>Be sure that the overflow holes don't clog up. If your sink starts to overflow, the water will run into the overflow holes, this might not be a huge issue, unless they are clogged. It's easy to maintain your plumbing, in this regard. When you're performing periodic checks, simply clear any overflow holes while checking for other potential problems.<br><br>Having water leaking into the dishwasher, however annoying, is luckily an easy fix. The hose that runs from the kitchen sink to the dishwasher is not installed properly, and can be corrected quickly. The water will not drain into the dishwasher from the sink if it is configured in an uphill and downhill position.<br><br>You can avoid plumbing issues if you know what to do and have the tools at hand to work with. By learning more about plumbing, a homeowner can make the right decisions and reduce the chance of plumbing problems. Also, a homeowner who researches solutions before working on plumbing will avoid potential disasters.
+
 
 +
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