Skip to content

Commit

Permalink
iData/corrcoef: use intersect prior to corrcoef
Browse files Browse the repository at this point in the history
Docs: Few notes on corrcoef and Load/Save
  • Loading branch information
farhi committed Sep 25, 2013
1 parent 44c07f2 commit 8e7529c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions Applications/standalone/deb/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Version: @IFIT_VERSION@
Architecture: arch
Installed-Size: 48100
Depends: bash
Recommends: mcrinstaller
Section: Science
Priority: optional
Homepage: http://ifit.mccode.org
Expand Down
5 changes: 3 additions & 2 deletions Docs/Loaders.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ <h3><a class="mozTocH3" name="mozTocId485865"></a>Supported data formats (defaul
The Loaders sub-library comes with a large number of predefined import
filters. These are tested one after the other, based on an initial
filter selection using the file name extension and optionally pattern
(wods) recognition in file headers. <br>
(words) recognition in file headers. <br>
A compact list of all supported formats is shown with <br>
<pre style="margin-left: 40px;">&gt;&gt; a = <span style="color: rgb(51, 102, 255);">iLoad</span>(<span style="color: rgb(204, 51, 204);">'formats'</span>);</pre>

Some of these formats can be written back, providing a vast conversion capability (see the <a href="Save.html">Save</a> page).<br>
The filters have been divided into two categories: those that directly
use formats natively known by Matlab, and those that are more specific
to neutron and X-ray communities (or other research areas).<br>
Expand All @@ -197,7 +198,7 @@ <h4><a class="mozTocH4" name="mozTocId876478"></a>Legacy data formats (text, Net
<td style="vertical-align: top; background-color: rgb(255, 204, 204); font-weight: bold; font-style: italic;">Description<br>
</td>
<td style="vertical-align: top; font-weight: bold;">iData/saveas<br>
Write<br>
<a href="Save.html">Write</a><br>
</td>
</tr>
<tr>
Expand Down
16 changes: 15 additions & 1 deletion Docs/Math.html
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,19 @@ <h3><a class="mozTocH3" name="mozTocId660745"></a>Binary operators</h3>
<td style="vertical-align: top;">interpolation (linear is
default, see <a href="#mozTocId991507">below)</a><br>
</td>
</tr>
</tr><tr>
<td style="vertical-align: top;"><span style="font-weight: bold;">corrcoef</span><br>
</td>
<td style="vertical-align: top;">cov(s1,s2)/&#963;(s1)&#963;(s2) in [-1:1]<br>
</td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;"><a href="http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient">Pearson correlation coefficient</a> <br>
</td>
</tr>

</tbody>
</table>
<br>
Expand Down Expand Up @@ -917,6 +929,8 @@ <h4><a class="mozTocH4" name="mozTocId121035"></a>Convolution/correlation</h4>
Similarly, the <span style="font-weight: bold;">xcorr</span> operator
computes the <a href="http://en.wikipedia.org/wiki/Cross-correlation">cross correlation</a> of two signals. The auto-correlation is simply
<span style="font-style: italic;">xcorr(a)</span>.<br>
<br>
Last, the <span style="font-weight: bold;">corrcoef</span> method returns the <a href="http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient">Pearson product-moment correlation coefficient</a>, which measures the similarity between two data sets. It returns a measure of the similarity between data sets (1=equal, 0=non correlated, -1=anti-correlated).<br>
<br><span style="color: rgb(255, 0, 0);">
Warning: </span>The accuracy of the <span style="font-style: italic;">conv</span> and <span style="font-style: italic;">xcorr</span>
operators depends on the axis sampling. A coarse axis sampling (that is
Expand Down
3 changes: 2 additions & 1 deletion Docs/Methods.html
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ <h3><a class="mozTocH3" name="mozTocId179983"></a><span style="font-weight: bold
<li><a href="matlab:doc iData/fits"><span style="font-weight: bold;">fits: </span></a>finds best model
parameters to fit the <span style="font-style: italic;">Signal. </span>New
fit functions/models can be created with the <a href="Models.html#mozTocId210092">iFunc/Model Builder</a> tool.</li>
<li><a href="matlab:doc iData/corrcoef"><b>corrcoef: </b></a>compute the correlation between an object and something else.<span style="font-style: italic;"> <br>
<li><a href="matlab:doc iData/corrcoef"><b>corrcoef: </b></a>compute the correlation (Pearson) between an object and something else.<span style="font-style: italic;"> <br>
</span></li>

</ul>
Expand Down Expand Up @@ -1002,4 +1002,5 @@ <h3><a class="mozTocH3" name="mozTocId341680"></a><span style="font-weight: bold




</body></html>
4 changes: 2 additions & 2 deletions Docs/Save.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h4><a class="mozTocH4" name="mozTocId593918"></a>text based lossless
be compressed afterwards with e.g. ZIP.<br>
<br>
The last column indicates if the generated format for export can be
re-used afterwards and re-imported with iFit.<br>
re-used afterwards and re-imported with iFit (see the <a href="Loaders.html">Loaders</a> and <a href="Load.html">Load</a> page).<br>
<span style="font-weight: bold;"><br>
</span>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
Expand Down Expand Up @@ -277,7 +277,7 @@ <h4><a class="mozTocH4" name="mozTocId238422"></a>binary lossless
workspace
binary
file is compact and fast to read/write. It carries the whole object
information. Such files require Matlab (or <a href="http://www.octave.org">Octave</a>) to be installed prior to
information. Such files require Matlab (or <a href="iFit.html">iFit standalone</a> or <a href="http://www.octave.org">Octave</a>) to be installed prior to
importation. <span style="font-style: italic;">This file contains serialized data, to be re-imported into an iData object.</span><span style="font-weight: bold;"> </span></td>
<td style="vertical-align: top;">Yes<br>
</td>
Expand Down
9 changes: 7 additions & 2 deletions Objects/@iData/corrcoef.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
% ex: b=corrcoef(a); c=corrcoef(a, gauss);
%
% Version: $Revision$
% See also iData, iData/mean, iData/fits
% See also corrcoef, iData, iData/mean, iData/fits

% either 'a' or 'b' is an iData
if nargin > 1 && isa(b, 'iData')
Expand Down Expand Up @@ -41,14 +41,19 @@
b = feval(b, NaN, a);
end

% find intersection
if isa(a, 'iData') && isa(b, 'iData')
[a,b] = intersect(a,b); % perform operation on intersection
end
% get the Signal of the two objects
if isa(b, 'iData')
b = getaxis(b, 0);
end
if isa(a, 'iData')
a = getaxis(a, 0);
end

if ~isnumeric(a) || ~isnumeric(b)
if ~isnumeric(a) || ~isnumeric(b) || numel(a) ~= numel(b)
c = [];
return
end
Expand Down

0 comments on commit 8e7529c

Please sign in to comment.