Prev: where to find libmatlb.h?
Next: Reading AVI files.
From: Randy Poe on 8 Feb 2005 11:07 Rod Gramlich wrote: > I can see how this sill work (i.e. appending a vector)- Yet it does, I do it all the time for generating plots which change in real time. Oh sorry, I see that you are saying you see how it works, not that you can't see how it works. > and I guess > the bottom line is that MATLAB doesn't have any equivalent to 'C' > .... i.e. plot (x,y), follwed by subsequent line_to(x,y) [as you add > points / samples]. I find it peculiar that MATLAB doesn't have such a > capability. Yet it has an equivalent capability, which I was exploiting. Matlab is array-oriented. Two of the properties of a line are the 'xdata' array and the 'ydata' array. Change those arrays and you will change the content of the plot. You also need the "drawnow" so that the plot is redrawn to reflect the changed properties. In a sense it is exactly the same as what you are talking about, because as soon as you add a new element to these arrays, the line is automatically extended to include the new element. And there's no "plot" or "line_to" inherent in the C language anyway. Apparently these are calls in some library you have used in the past, but there's no graphics standard in standard C. I've never seen these calls, though it's obvious what the usage is from your description. You certainly could create new lines each time you added a data point, from your old point to your new one. This would create N line objects, each of which contains 2 data points. The method I suggest is much cleaner and quicker. - Randy
From: Steve Amphlett on 8 Feb 2005 11:11 Randy Poe wrote: > <snip> > > > You certainly could create new lines each time you > added a data point, from your old point to your new > one. This would create N line objects, each of which > contains 2 data points. The method I suggest is > much cleaner and quicker. What I often do is to 'preallocate' my plot by plotting a vector of NaN vs NaN that doesn't show. Then replace the NaNs with computed values as they appear.
From: Randy Poe on 8 Feb 2005 12:01 Rod Gramlich wrote: > I can see how this sill work (i.e. appending a vector)- Yet it does, I do it all the time for generating plots which change in real time. Oh sorry, I see that you are saying you see how it works, not that you can't see how it works. > and I guess > the bottom line is that MATLAB doesn't have any equivalent to 'C' > .... i.e. plot (x,y), follwed by subsequent line_to(x,y) [as you add > points / samples]. I find it peculiar that MATLAB doesn't have such a > capability. Yet it has an equivalent capability, which I was exploiting. Matlab is array-oriented. Two of the properties of a line are the 'xdata' array and the 'ydata' array. Change those arrays and you will change the content of the plot. You also need the "drawnow" so that the plot is redrawn to reflect the changed properties. In a sense it is exactly the same as what you are talking about, because as soon as you add a new element to these arrays, the line is automatically extended to include the new element. You certainly could create new lines each time you added a data point, from your old point to your new one. This would create N line objects, each of which contains 2 data points. The method I suggest is much cleaner and quicker. - Randy
From: Rod Gramlich on 8 Feb 2005 12:37 Steve Amphlett wrote: > > Uh? What version of 'C' are you using? I don't recall any > functions > like that in any of the ANSI standards. Borland C. Just add an ANSI driver in DOS to allow graphics (Turbo C) commands. Line(x1,y1,x2,y2) draws a line from x1y1 to x2y2. Lineto(x,y) draws a line from LAST x,y coordinate to x,y coordinate in lineto(x,y).
From: Steve Amphlett on 8 Feb 2005 13:01
Rod Gramlich wrote: > > > Steve Amphlett wrote: >> >> Uh? What version of 'C' are you using? I don't recall any >> functions >> like that in any of the ANSI standards. > > Borland C. Just add an ANSI driver in DOS to allow graphics (Turbo > C) > commands. Line(x1,y1,x2,y2) draws a line from x1y1 to x2y2. > Lineto(x,y) draws a line from LAST x,y coordinate to x,y coordinate > in lineto(x,y). Try posting that kind of talk in comp.lang.c ! |