Hi it's the first time I want to use the parallel toolbox from matlab. I have this loop
for y=1:size(pxyvector,1)
if (strcmp(pxyvector{y,1}, emotionword))&&(strcmp(pxyvector{y,2},tweet{x}))
pxyvector{y,3} = pxyvector{y,3} +1;
invector = true;
end
end
How would I go and make this work in a parallel for. I read the sliced variables part of matlab, but I don't get how I can do this here.
pxyvector is a 100000x3 cell array
tweet{x} is a string
emotionword is a string too.
invector is a value that is used later outside the loop.
So basically I compare the first value from a row of the pxyvector with the emotion word, and the second value from a row of the pxyvector to tweet{x}. If they are the same. The third value in the row gets incremented.
During the loop the same value cannot be incremented twice.
The problems in this for loop are that I need to change a variable that is used outside the loop too and increment a value.
Some data to play with : http://ojtwist.be/pxyvector.mat (variable is pxyvector2 in this .mat file, so change that in the code, if you want to test it)
pxyvectorseems fine to me as only one row is touched at a time, i.e., it should be fine to calculate it in parallel. However,invectoris a problem. How about changing that line toinvector(y) = true;? Then it should run in theparforloop too. After the loop, just useinvector = any(invector);. - H.Muster