Prev: Determine eccentric points on a rotated ellipse?
Next: How to use matlab in terminal in ubuntu?
From: Anthony on 10 Apr 2010 15:44 Hey Bruno, Just found out I'm not allowed to use any C scripts to solve my problem. But that function works really well, so thanks! Would you be a way to make the loop faster using only MATLAB functions? Thanks Anthony
From: Bruno Luong on 10 Apr 2010 15:53 "Anthony " <antfarinaccio(a)gmail.comremove.spam> wrote in message <hpqke4$4uo$1(a)fred.mathworks.com>... > Hey Bruno, > > Just found out I'm not allowed to use any C scripts to solve my problem. But that function works really well, so thanks! > > Would you be a way to make the loop faster using only MATLAB functions? The function minmaxfilt performs equivalently to the so-called "morphology" operation in image processing language. If you own the image processing toolbox, I think you can replace the call of minmaxfilt with the dilatation function imdilate(). I don't have the toolbox, so might be someone else can guide you from there. Bruno
From: Matt Fig on 10 Apr 2010 20:43 This runs in about half the time of your original loops on my machine. SP = [true(NSims,1),(StockPrice>H).']; ParisPayoffs3 = zeros(1,NSims); st = [1 zeros(1,D)]; for ii = 1:NSims if isempty(strfind(SP(ii,:),st)) ParisPayoffs3(ii) = max(StockPrice(Length+1,ii)-K,0); end end
From: Matt Fig on 10 Apr 2010 23:21 "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hpr5up$ika$1(a)fred.mathworks.com>... > This runs in about half the time of your original loops on my machine. > > > SP = [true(NSims,1),(StockPrice>H).']; > ParisPayoffs3 = zeros(1,NSims); > st = [1 zeros(1,D)]; > > for ii = 1:NSims > if isempty(strfind(SP(ii,:),st)) > ParisPayoffs3(ii) = max(StockPrice(Length+1,ii)-K,0); > end > end This may be even faster on some systems: idx = [ones(1,NSims);(StockPrice>H);inf(1,NSims)]; idx = strfind(idx(:).',[1 zeros(1,D)]); ParisPayoffs4 = max(StockPrice(Length+1,:)-K,0); ParisPayoffs4(ceil(idx/(Length+3))) = 0;
From: Anthony on 11 Apr 2010 00:50 These work great Matt! Thanks very much! Anthony
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Determine eccentric points on a rotated ellipse? Next: How to use matlab in terminal in ubuntu? |