This question already has answers here:
List all files in a directory given a regular expression / a set of extensions (Matlab)
(3 answers)
Matlab equivalent of `endsWith`: How to filter list of filenames regarding their extension?
(1 answer)
Closed 7 years ago.
I want to be able to detect a file by looking at its extension:
.m,
.fig,
.mdl,
.slx
but not
.mat
or others.
The final use will be to call DIR with a regular expression that filters out all the unnecessary files.
My first obstacle was to define a word of a single character "m". I couldn't figure out which expression should I use for REGEXP, and the documentation of Matlab was not clear enough.
An example of usage will be helpful, and a reference to a more understandable place will be very appreciated.
Related
This question already has answers here:
What does two dots before a slash mean? (../) [closed]
(1 answer)
What do the dots mean in relative file path?
(5 answers)
What does a dot mean in a URL path?
(3 answers)
Closed 4 years ago.
I stumble across some MATLAB codes about data file paths, something like:
data=csvread(sprintf('../data/cdflevel%dtable.csv',cdflevels(i)));
I am not sure what '../' does. Anyone can explain it?
../ moves one folder up from the current directory, before then changing to the data directory in the parent folder. It's not specific to MATLAB, just a standard way of navigating a file system.
This question already has an answer here:
Export data from matlab to csv [duplicate]
(1 answer)
Closed 7 years ago.
I can't seem to find the correct syntax for this. My code loads a file "sensordata.mat" that is called "temps", and uses this for results. At the end of the code it should write my data to a csv file. I tried the following:
writetable('sensordata.csv','temps')
This only gives me an error stating:Undefined function 'write' for input arguments of type 'char'.
Does anyone know the solution for this? Thank you for your expertise.
CSV support is built into MATLAB:
csvwrite('sensordata.csv', temps);
This question already has answers here:
How to save a structure array to a text file
(3 answers)
Closed 8 years ago.
I am an R user: I don't use Matlab. However, I am working with a genomic file from the Broad Institute called "hg18_with_miR_20080407.mat". You can find it at: http://genepattern.broadinstitute.org/ftp/distribution/genepattern/dev_archive/GISTIC/broad.mit.edu:cancer.software.genepattern.module.analysis/00125/1.1/
I tried to use the R package R.matlab (table <- readMat("~/desktop/hg18_with_miR_20080407.mat")), but it keeps loading in definitively. Hence, since I need that file today, I used a friend's computer with Matlab. I have a struct <1x26835> called rg
Each variable has the following values:
refseq 'NM_003585'
gene 'double C2...'
symb 'DOC2B'
locus_id 8447
...
Is there a way that I can print each entry into a text file that I could easily parse? Is there a better way? I am reading the Matlab documentation but would appreciate if someone could give me a one-liner. If not possible, how could I search each variable for a specific gene entry? I keep getting errors. For example:
find(rg == 'Met')
Error: The expression to the left of the equals sign is not a valid target for an assignment.
Thank you!
I recommend trying YAML files (site).
There are libraries for writing matlab data into it here that I have used and liked and googling shows me that there appear to be libraries for R as well.
YAML is basically a newer version of XML files that is human readable, simpler, and less extensible.
This question already has answers here:
How to get all files under a specific directory in MATLAB?
(8 answers)
Closed 8 years ago.
I have my data in multiple folders. Let's say I have a folder containing 100 subfolders at the moment that look like this:
/folder/Re0001/vitesse
/folder/Re0002/vitesse
/folder/Re000N/vitesse
/folder/Re000N+1/vitesse
/folder/Re0100/vitesse
I want to import the vitesse file into a cell array. This is the code that i am using at the moment:
numfiles=100;
mydata=cell(1,numfiles);
for i=1:numfiles
mydata{i}=uiimport;
end
It is a working solution.
However, if it involves 100 or more files I have to specify each folders and files manually, which is very troublesome.
By the way I am new to Matlab so can you please incorporate example code with the directory given.
I did something similar few days ago. Have a look at the matlab function ls. If you are using windows system, you are all set. If your are using linux, you may need to split the results. However newer version of matlab have the strsplit function that will do the job, or you will use regular expressions.
In your case,
list = ls('/folder/*/vitesse');
will give you a list of your files.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Where can I find a CSV to NSArray parser for Objective-C?
I have the CSV file like this:
vv pp
96.84686 86.38099
How to read this file in the objective c and pass in the array
There are some open source csv parser available search on google for that. you will find one in github. Here is one to help you https://github.com/davedelong/CHCSVParser