diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/BNT/learning/CovMat.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/BNT/learning/CovMat.m')
| -rw-r--r-- | sourcecodes/bnt-master/BNT/learning/CovMat.m | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/learning/CovMat.m b/sourcecodes/bnt-master/BNT/learning/CovMat.m new file mode 100644 index 00000000..9b788172 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/learning/CovMat.m @@ -0,0 +1,39 @@ +function [CovMatrix, obs, varfields] = CovMat(filename,row_cols) +%[CovMatrix, obs, varfields] = CovMat(filename,row_cols) +%% generates a Covariance Matrix from a file of data consisting of N columns of M data rows +%% filename string name (with path and extension) of file to open +%% row_cols Number_of_converstions_per_row (turns into [3 inf]) +%% Return +%% CovMatrix Covariance matrix +%% obs Number of observations read in +%% varfields Labels of the variables see filename structure below +%% +%% Filename structure: +%% Comma separated, starting with the variable labels, then the data in rows. +%% filename test.txt consists of: +%% +%% Earthquake,Burglar,Radio,Alarm,Call +%% 1,2,3,4,5 +%% 11,22,33,44,55 +%% . . . +%% +%% Example call: +%% [cvmat numdat lables] = CovMat('test.txt',5); +%% +%% Returns Covariance matrix, number of date rows and variable field names +%% Gary R. Bradski 7/2002 + +fmtstr = '%f'; +for i = 2:row_cols + fmtstr = strcat(fmtstr,',%f'); +end + +%% load data +fidCov = fopen(filename,'r'); + +varfields = fgetl(fidCov); +Corx = fscanf(fidCov,fmtstr,[row_cols inf]); +Corx= Corx'; +[obs bla] = size(Corx); +CovMatrix = cov(Corx); +fclose(fidCov); \ No newline at end of file |
