I am currently doing a project that requires the usage of the line function in Matlab. Lines are plotted using the line function on a graph. The code is something like this:
for i=0:N-1
    for j=0:N-1
        a = ...
        b = ...
        line(a,b,'...','.5')
    end
end
This is a part of a function and is called repeatedly. Thus multiple graphs such as these are created. Once I start executing the program, I want to automatically save these graphs as bitmap images. Is there any way to do that?
I tried using handles but wasn't very successful. The imsave function doesn't help since line doesn't return a matrix of the graph it produces. I looked into saveas, but couldn't get very far. Is there any way to do it?