필터 지우기
필터 지우기

Matlab does wired stuff

조회 수: 1 (최근 30일)
bethel o
bethel o 2011년 2월 21일
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
bethel o
bethel o 2011년 2월 21일
@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 2011년 2월 21일
I noticed that :-) - can't edit the comments

댓글을 달려면 로그인하십시오.

채택된 답변

Paulo Silva
Paulo Silva 2011년 2월 21일
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
bethel o
bethel o 2011년 2월 21일
yep cheers that one is corrected. but the issue remains.
Paulo Silva
Paulo Silva 2011년 2월 21일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

bethel o
bethel o 2011년 2월 21일
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
bethel o
bethel o 2011년 2월 21일
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 2011년 2월 21일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by