想知道怎么完全随机来显现字组?不是前一半积极词在左,后一半在右这种,而是完全打乱的那种
直接放个例子吧,直观:
a={'红','绿','蓝'};
b=length(a);
c=randperm(b)
for i=1:b
d=c(i);%随即顺序
e(i)=a(d);
end
a=e;
a={'红','绿','蓝'};
b=length(a);
c=randperm(b)
for i=1:b
d=c(i);%随即顺序
e(i)=a(d);
end
a=e;
positive={'喜悦','开心'};
negative={'难过','悲伤'};
count=0;
for i=1:length(positive)
for j=1:length(negative)
count=count+1;
StimInd(count).word1=positive{i};
StimInd(count).word2=negative{j};
end
end
for n=1:i*j
StimInd(i*j+n).word1=StimInd(n).word2;
StimInd(i*j+n).word2=StimInd(n).word1;
end
引用上课大佬们的代码
negative={'难过','悲伤'};
count=0;
for i=1:length(positive)
for j=1:length(negative)
count=count+1;
StimInd(count).word1=positive{i};
StimInd(count).word2=negative{j};
end
end
for n=1:i*j
StimInd(i*j+n).word1=StimInd(n).word2;
StimInd(i*j+n).word2=StimInd(n).word1;
end
引用上课大佬们的代码