Question about ismember function
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 9 Jun 2013
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 Comments
Walter Roberson
on 9 Jun 2013
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.
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!