How do I use intersect(A,B,'legacy') correctly in my case?

1 view (last 30 days)
Hello MATLAB community, I am currently using a code from a scientific paper. The code was written with MATLAB 2012b, which means that the behaviour of 'intersect' has changed in newer releases. In order to run the code properly I have to replace all intersect(A,B) by intersect(A,B,'legacy'),according to https://de.mathworks.com/help/matlab/ref/intersect.html . Unfortunately I ran into a problem in this part of the code:
for i=1:N
gvarspecstartemp = [];
for j=1:cstypenum
eval(['starvec.vars{i,j} = intersect(gvarspec.',char(cskeys(i,1)),'.star,endovecfull{j});'])
gvarspecstartemp = [gvarspecstartemp, starvec.vars{i,j}];
end
eval(['gvarspec.',char(cskeys(i,1)),'.star = gvarspecstartemp;'])
end
I do not know how to replace the command in
eval(['starvec.vars{i,j} = intersect(gvarspec.',char(cskeys(i,1)),'.star,endovecfull{j});'])
I already tried these ways:
eval(['starvec.vars{i,j} = intersect(gvarspec.',char(cskeys(i,1)),'.star,endovecfull{j},'legacy');'])
eval(['starvec.vars{i,j} = intersect(gvarspec.',char(cskeys(i,1)),'.star,endovecfull{j},legacy);'])
I would really appreciate your help. Thank you.

Accepted Answer

the cyclist
the cyclist on 8 Aug 2017
Edited: the cyclist on 8 Aug 2017
I think you want
eval(['starvec.vars{i,j} = intersect(gvarspec.',char(cskeys(i,1)),'.star,endovecfull{j},''legacy'');'])
You need to double the single-quote characters, to tell MATLAB that they are part of the string, not delimiting the string.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!