Question about ismember function
조회 수: 1 (최근 30일)
이전 댓글 표시
I created a variable that stores a set of numbers for an arc (a,b). Sc{1,2} = [1,2]; Sc{2,1} = [1,2]; Sc{1,3} = [2]; Sc{3,1} = [2]; Sc{3,4} = [1,2]; Sc{4,3} = [1,2]; Sc{2,4} = [1]; Sc{4,2} = [1];
I would like to implement the following condition:
s{1} = [1,2];
for v = 1:n,
if s{v} is a subset of s{u}
s{v} = intersect( s{u},Sc{u,v});
end;
end;
I dont know how to code 'if s{v} is a subset of s{u}' in matlab. please help I tried the ismember function:
if(ismember(scenarios{v},scenarios {u}))
but it is showing the following error:
Index exceeds matrix dimensions
댓글 수: 0
답변 (1개)
Walter Roberson
2013년 6월 9일
That error could arise if either u or v exceeded length(s) . You have not shown us how u is being controlled, and have not shown us the relationship between "n" and length(s) .
댓글 수: 3
Walter Roberson
2013년 6월 9일
At the MATLAB command line give the command
dbstop if error
then run your program. When it stops with the error message, examine the values of u, and v, and size(scenarios) . Also give the command
which ismember
just in case "ismember" got overwritten as a function.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!