0

I'm running a simulation that describes activity at the front and back of a 2D, square lattice. the front and back are described for example by:

front= [-1 1 -1 0 1 0 1  2 -2 1 ];
back = [ 1 0  0 0 2 0 1 -2 -2 1 ];

each number indicates different activity on the lattice.

I want to plot this interactively so that each value in the lattice will be marked by a different marker and color and the plot will be updated every iteration. So far I have something like:

    % the upper and lower edges of the lattice
    figure (1)
    hold on
    plot(linspace(1,100,10),10*ones(1,10),'k'); %front
    plot(linspace(1,100,10),1*ones(1,10),'k'); %back
    % the front and back when are equal 0 zero (initial condition)
    plot(100*ones(1,10),1:10,'ob','markersize',10); % front
    plot(1*ones(1,10),1:10,'ob','markersize',10); % back
    xlim([-1 101])
    ylim([-1 11])

This marks the initial setup of the system I'm working on, plot it to see what I'm referring to.

now in each iteration I want to view the circles change colors for different values, for example:

figure (1)
ind=find(front==1);
if (isenum(ind)==0)
    plot(100*ones(1,length(ind)),ind,'or','markerfacecolor','r');
end

This is done 10 times, for 5 values at the front and 5 at the back, and is quite heavy on the simulation I wish to find a way that I can span the entire vector front/back on the lattice with "one go" and have different markers assigned to each value. I manage to do it with imagesc, however, I lose the graphics I want to keep while piloting the markers (I wish to add arrows and other stuff later as well). does anyone have any experience with these kind of things?

John Paul
  • 12,196
  • 6
  • 55
  • 75
jarhead
  • 1,821
  • 4
  • 26
  • 46
  • You are not using the `front` and `back` variables as defined here (probably in your extended code you do), and I don't quite get what you mean by the coloured circles, care to elaborate on that? – Adriaan Sep 11 '15 at 11:21
  • yes: 0 - blue color, 1 - red color 2- black color , etc...., they change every iteration – jarhead Sep 11 '15 at 11:24
  • I think you are working in a `for` loop, in which case you can create a colour-vector containing those colours and call the required colour each time you make a plot, using the corresponding index to the colour vector – Adriaan Sep 11 '15 at 11:26
  • yes, but this does not solve the problem, I still have to find the indexes of each value and have a condtition since sometimes there are no values at all and ind=[]. I'll add something in the post – jarhead Sep 11 '15 at 11:32

0 Answers0