Borrar filtros
Borrar filtros

Matlab does wired stuff

1 visualización (últimos 30 días)
bethel o
bethel o el 21 de Feb. de 2011
This is part of a function that is doing what i called wired. The vector 'dim_set' in this snippet should expanded on both side depending on the value of the scalar 'const'. I have no idea while the result is wired. Pls help!
% expand dim_set by 1 or a const on each side
dim_set=[67.5:100.5];
const=20;
dim_set %befor
dim_set=floor(dim_set);
if(dim_set(1)>1)
dim_set=[dim_set(1)-const:dim_set(1),dim_set];
end
dim_set=[dim_set,dim_set(end):dim_set(end)+const];
% See befoer and after values of dim_set to see this
dim_set %after
  6 comentarios
bethel o
bethel o el 21 de Feb. de 2011
@Andreas Goser. i meant weird. I have been coding for stegers algorithm constantly for one week now, so am tired. And by the way is it 'ot weird' or 'or weird'?. lol there
Andreas Goser
Andreas Goser el 21 de Feb. de 2011
I noticed that :-) - can't edit the comments

Iniciar sesión para comentar.

Respuesta aceptada

Paulo Silva
Paulo Silva el 21 de Feb. de 2011
dim_set=67.5:1:100.5
const=20;
dim_set %before
dim_set=floor(dim_set); %have no clue what's the purpose of this line
dim_set=[dim_set(1)-const:dim_set(1)-1 dim_set]; %expand left
dim_set=[dim_set dim_set(end)+1:dim_set(end)+const]; %expand right
% See before and after values of dim_set to see this
dim_set %after
  5 comentarios
bethel o
bethel o el 21 de Feb. de 2011
yep cheers that one is corrected. but the issue remains.
Paulo Silva
Paulo Silva el 21 de Feb. de 2011
You were correct, now that I know what your function does I came to the conclusion that the borders are irrelevant but there's no need to waste a little more memory with duplicated values.

Iniciar sesión para comentar.

Más respuestas (1)

bethel o
bethel o el 21 de Feb. de 2011
function tf=intersect_l(dim_set,memb)
% expand dim_set by 1 or a const on each side
%dim_set=[67.5:100.5];
const=20;
dim_set %befor
dim_set=floor(dim_set);
if(dim_set(1)>1)
dim_set=[dim_set(1)-const:dim_set(1),dim_set];
end
dim_set=[dim_set,dim_set(end):dim_set(end)+const];
dim_set %after
if(intersect(dim_set,memb))
tf=1;
else
tf=0;
end
end
  9 comentarios
bethel o
bethel o el 21 de Feb. de 2011
Thanks a lot Paulo. I have also tried it and it works, outside of its parent function (because its a sub function). I have no idea why it dosn't work for certain values of 'const' when ran through the parent function but works for all values of 'const' when ran as a function on its own.
I will have a sleep and come back to it.
Thanks alot for your assistance.
Bethel
bethel o
bethel o el 21 de Feb. de 2011
Hey Paulo, I did not realize that in programing if I have something like
IF(i && j), j will not be checked if i =false . this was simply the problem I was having. I was checking the output of j and only saw it some times (i and j are functions that returns boolean in my program). I did not know that the reason I was not seeing j sometimes was because sometimes i =false.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by