Prev: Is it possible to run multiple target PCs simultaneously with
Next: mcc returns '??? Error executing mcc, return status = 1.'
From: Bwana on 6 Jul 2010 16:28 Hello All, I'm trying to create the equivalent of the Renko chart in an array form. Long story short say i have a list of numbers: [xxxx.xxxx 1 xxxx.xxxx 2 xxxx.xxxx 3 xxxx.xxxx 4 .... xxxx.xxxx n-1 xxxx.xxxx] n Suppose i want to record numbers into a new array only when the difference has exceeded some fixed value z. say the difference between number 2 and 1 above is less than z, nothing is recorded. But if the number between 3 and 1 is greater than z, then 3 is recorded. Then if the difference between 4 and 3 is less than z, nothing is recorded, but if the number between 5 and 3 is greater than z, then 5 is recorded, so on and so forth. I have this bit of code for 'dummy' of size 2500(r) x 6(c): for i = 1:max(size(dummy)) for j = 1:max(size(dummy)) for k = i:max(size(dummy)) if abs(dummy(j,5) - dummy(k,5)) > z dummy_1(j,:) = dummy(k,:); end end end end But this ends up giving the original 2500 x 6 matrix and seems really inefficient. Am i thinking about this the correct way? Your time and efforts are appreciated.
From: Bwana on 7 Jul 2010 08:29 "Bwana " <bwana.mukubwa(a)gmail.com> wrote in message <i103l9$7v1$1(a)fred.mathworks.com>... > Hello All, > > I'm trying to create the equivalent of the Renko chart in an array form. > > Long story short say i have a list of numbers: > > [xxxx.xxxx 1 > xxxx.xxxx 2 > xxxx.xxxx 3 > xxxx.xxxx 4 > ... > xxxx.xxxx n-1 > xxxx.xxxx] n > > Suppose i want to record numbers into a new array only when the difference has exceeded some fixed value z. > > say the difference between number 2 and 1 above is less than z, nothing is recorded. But if the number between 3 and 1 is greater than z, then 3 is recorded. Then if the difference between 4 and 3 is less than z, nothing is recorded, but if the number between 5 and 3 is greater than z, then 5 is recorded, so on and so forth. > > I have this bit of code for 'dummy' of size 2500(r) x 6(c): > > for i = 1:max(size(dummy)) > for j = 1:max(size(dummy)) > for k = i:max(size(dummy)) > if abs(dummy(j,5) - dummy(k,5)) > z > dummy_1(j,:) = dummy(k,:); > end > end > end > end > > But this ends up giving the original 2500 x 6 matrix and seems really inefficient. > > Am i thinking about this the correct way? > > Your time and efforts are appreciated. Found a solution: inputs = GBPJPY(1,:); threshold = 1.00; % for i = 1:max(size(GBPJPY)) for j = i:max(size(GBPJPY)) if abs(GBPJPY(j,5) - GBPJPY(i,5)) > threshold inputs(j,:) = GBPJPY(j,:); i = j; % use this next part to check that the difference is > threshold is true dummy(j,1) = inputs(j,5); dummy(j,2) = GBPJPY(j,5) - GBPJPY(j-1,5); end end end % inputs(~any(inputs,2),:) = [];
From: Steven Lord on 7 Jul 2010 09:39
"Bwana " <bwana.mukubwa(a)gmail.com> wrote in message news:i11ruh$4h1$1(a)fred.mathworks.com... > "Bwana " <bwana.mukubwa(a)gmail.com> wrote in message > <i103l9$7v1$1(a)fred.mathworks.com>... >> Hello All, >> >> I'm trying to create the equivalent of the Renko chart in an array form. >> >> Long story short say i have a list of numbers: >> >> [xxxx.xxxx 1 >> xxxx.xxxx 2 >> xxxx.xxxx 3 >> xxxx.xxxx 4 >> ... >> xxxx.xxxx n-1 >> xxxx.xxxx] n >> >> Suppose i want to record numbers into a new array only when the >> difference has exceeded some fixed value z. >> >> say the difference between number 2 and 1 above is less than z, nothing >> is recorded. But if the number between 3 and 1 is greater than z, then 3 >> is recorded. Then if the difference between 4 and 3 is less than z, >> nothing is recorded, but if the number between 5 and 3 is greater than z, >> then 5 is recorded, so on and so forth. Use the DIFF function. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com |