Rank: 301409 based on 0 downloads (last 30 days) and 0 file submitted
photo

mathworks2011

E-mail
Company/University
Cambridge

Personal Profile:

 

Watch this Author's files

 

Comments and Ratings by mathworks2011 View all
Updated File Comments Rating
19 Oct 2011 Round to a Specified Number of Significant Digits Rounds a numeric array to a specified number of Significant Digits. Author: Edward Zechmann

17 Oct 2011 Tick2Bar Divides a time series into periods and returns high, low, open, close, volume. Author: Michael Robbins

sorry - copied an old version in by mistake. Pls see below:

function trade =cce_Tick2Bar_synchronous(t,p,g)
% error check
[t,tix]=sort(t);
p=p(tix);
vix=~isnan(p);
t=t(vix);
p=p(vix);

% create bins
mySynchTime=[floor(min(t)):g:ceil(max(t))];
[n,bin]=histc(t,mySynchTime); % n is the number of obs per bin

% pre-allocate
C=NaN(numel(n),1);
for i = 1: length(mySynchTime)
if(i==1)
from = 1;
elseif(i == length(mySynchTime))
from = cumsum(n(1:i-1));
from = from(end);
else
from = cumsum(n(1: i-1));
from = from(end) + 1;
end
to =cumsum(n(1:i));
to = to(end);

% These are the index numbers you are accessing
%disp([num2str(from) ' ' num2str(to)]);

%Observe which timestamps you are taking.
%disp(datestr(t(from:to)));

% As you are interested in the close, just take the last value
tmp = p(from:to);
if(isempty(tmp) && i ~=1)
%we have no observations in that window. Thus no price change.
tmp = C(i-1,1);
elseif(isempty(tmp) && i ==1)
%Special case. we are right at the start.
tmp = p(1);
end
C(i,1) = tmp(end);
clear tmp;
end

% Make sure you align correctly!
trade = timeseries(C(1:end-1), mySynchTime(2:end));

end

17 Oct 2011 Tick2Bar Divides a time series into periods and returns high, low, open, close, volume. Author: Michael Robbins

a good effort. Doesnt support synchronous data though. ie you may have a security which trades infrequently, yet you still want to map it on a discrete grid:

function trade =cce_Tick2Bar_synchronous(t,p,g)
% error check
[t,tix]=sort(t);
p=p(tix);
vix=~isnan(p);
t=t(vix);
p=p(vix);

% create bins
mySynchTime=[floor(min(t)):g:ceil(max(t))];
[n,bin]=histc(t,mySynchTime); % n is the number of obs per bin

% pre-allocate
C=NaN(n,1);
for i = 1: length(mySynchTime)
if(i==1)
from = 1;
to = cumsum(n(1:i));
to = to(end);
elseif(i == length(mySynchTime))
from = cumsum(n(1:i-1));
from = from(end);
to =cumsum(n(1:i));
to = to(end);
else
from = cumsum(n(1: i-1));
from = from(end) + 1;
to =cumsum(n(1:i));
to = to(end);
end
% These are the index numbers you are accessing
%disp([num2str(from) ' ' num2str(to)]);

%Observe which timestamps you are taking.
%disp(datestr(t(from:to)));

% As you are interested in the close, just take the last value
tmp = p(from:to);
if(isempty(tmp))
%we have no observations in that window. Thus no price change.
tmp = C(i-1,1);
end
C(i,1) = tmp(end);
clear tmp;
end

% Make sure you align correctly!
trade = timeseries(C(1:end-1), mySynchTime(2:end));

end

22 Sep 2011 plot3c Plots data color coded in 3D. Author: Ulrich Theune

basic but effective.

26 Jul 2011 Extract text from a PDF document (if you are lucky) Author: Dimitri Shvorob

V Poor. Does not work.

The author even notes it does not work inside the m-file!

java.lang.Throwable: Warning: You did not close the PDF Document
at org.pdfbox.cos.COSDocument.finalize(COSDocument.java:418)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

Contact us