Simple Matlab/Octave Commands to Process Data
2012-12-07 03:32
190 查看
To load data in following format stored in a text file "read_pos' into Matlab/Octave, use commands<br />
Then data of the second column are stored in variable y.
If there are only numbers stored in file "read_pos", following commands should be used:
A matlab function to plot multiple datasets:
To use it, call
f=fopen('read_pos','r'); % open file a=textscan(f,'%s%d'); % read file y=a{2}; % a is a cell: a{1} stores read id, a{2} stores numbers.
Then data of the second column are stored in variable y.
r12353.1 2407054.5 r12361.1 5328858.5 r12363.1 2360272 r12368.1 4726440.5 r12372.1 2224001 r12373.1 5165613.5 r12381.1 501776 r12385.1 3475398 r12394.1 3376364 r12401.1 2142875.5 r12411.1 2191090.5 r12419.1 1240590 r12420.1 4903572 r12422.1 767011.5 r12426.1 3575915.5 r12429.1 554956 r12433.1 4786335 r12435.1 3373955.5 r12442.1 5363611.5 r12452.1 1903660.5 r12454.1 2784165 r12466.1 5137479 r12470.1 592191
If there are only numbers stored in file "read_pos", following commands should be used:
f=fopen('read_pos','r'); % open file a=textscan(f,'%s%d'); % read file y=cell2mat{a}; % convert cell a to vector size(y) % check the sizeTo plot the distribution of all the numbers, you can:
x=zeros(size(y)); plot(y,x,'bo');If another data set z is also loaded and you want to plot y and z in the same graph, you can:
figureTo annotate and scale the graph, use commands;
x=zeros(size(y)); plot(y,x,'bo');
hold on
x=ones(size(z));
plot(z,x,'r+');
xlabel('AMD Data k-mer Occurrances'); title('GPD Classification of AMD k-mers') legend('Bin 1','Bin 2') axis([-5 5 0 10000]) % scale axes
A matlab function to plot multiple datasets:
function result=plot_distr(varargin) nVarargs=length(varargin); marker={'bo' 'r+' 'k*' 'gs' 'y^' 'md' 'cp' 'bx' 'r.' 'k>' 'gh' 'y<'}; figure for k=1:nVarargs f=fopen(varargin{k},'r'); a=textscan(f,'%d'); y=cell2mat(a); x=zeros(size(y))+k; plot(y,x,marker{k}); hold on end ylim([0-5*nVarargs 6*nVarargs]); % scale y-axis
To use it, call
plot_distr('file1','file2',...,'filen').
相关文章推荐
- Simple Excel to connect to the database and display filtered data.
- How to convert simple data to a geodatabase
- Simple VBScript program to extract data from all worksheets in an Excel spreadsheet
- OPENXML to Publish and Process XML Data
- Sending Simple Data to Other Apps
- cassandra compaction; how to process tombstone data
- Simple VBScript program to extract data from all worksheets in an Excel spreadsheet
- media foundation (Using the Source Reader to Process Media Data)
- MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error
- PHP Encrypt/Decrypt: Simple class to encrypt url data
- Simple Introduction to Dirichlet Process
- linux oracle ORA-01221: data file 1 is not the same file to a background process
- (R)?ex - A simple framework to simplify system administration and datacenter automation
- Isight unable to evaluate matlab commands的解决办法
- #Redis Error #MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details a
- Simple way to export SQL Server data to Text Files
- Simple Path Data Resources that I Add to Every WPF and Silverlight Project
- load data to matlab
- MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error
- FNDLOAD Commands to Download Different Seed Data Types. (DOC ID 274667.1)