Reputation: 24067
I now have such code:
fDeals = fopen([logsFolder stock '_deals.log']);
data = textscan(fDeals, '%f:%f:%f:%f %f,%f %f,%f %f,%f %f');
fclose(fDeals);
% hh:min:sec:millisec
secvec = [60*60 60 1 1e-3];
x = [data{1:4}] * secvec';
flvec = [1 1e-16];
y = [data{5:6}] * flvec';
ammount = data{11};
xindays = x / (24*60*60);
plot(xindays, y, 'go','MarkerSize',6,'LineWidth',3);
It works fine but it always create green marker. I need to create green marker if amount > 0 otherwise I want to create red marker. How to do that?
Likely i should create separate xGreen
, xRed
, yGreen
, yRed
arrays, but then I need to separate file lines into two groups somehow - lines with >0 amount and lines with <0 amount (amount is never 0).
Upvotes: 1
Views: 2547
Reputation: 124573
You could also use the GSCATTER function from the Statistics Toolbox:
group = ammount > 0;
h = gscatter(xindays, y, group, 'gr', 'o', 6);
set(h, 'LineWidth',3)
legend(h, {'group 1','group 2'})
Upvotes: 1
Reputation: 9317
You can try this:
markerIDX = ammount > 0;
plot(xindays(markerIDX), y(markerIDX), 'go','MarkerSize',6,'LineWidth',3);
plot(xindays(~markerIDX), y(~markerIDX), 'ro','MarkerSize',6,'LineWidth',3);
Note, however, that this only works if xindays
, y
, and ammount
are of the same size.
Upvotes: 2