Prev: Generalized Ridge Regression
Next: 2d dct type-1
From: dpb on 29 Mar 2010 09:40 Dave ba wrote: > thank you dpb, for your help. although size is a important issue for a > program, ... Yes, I was just speaking in ML-programming generalities of good practice here... > my main focus is still on the program's lacking of saving the > previous data. i've tried to reposition the code of creating the > variable to somewhere before the clicking. but this variable musst > become a global, to request it later on. so the code that says the > variable is zero is gone, but is now replaced by requesting the > variable, which eventually still put's it back to zero after a point is > clicked. > I'm clearly doing something wrong here, but I cant figure out what.. .... OK, now you're into the structure of the Matlab GUI and that's really beyond my ken (I don't do windows, to borrow a phrase :) ) I've never written a gui interface in my career and don't intend to start now, but -- Read the section on "Managing GUI Data" and if you're not using GUIDE, the subsection "If You Are Not Using a Handle Structure" on how to use the GUI figure's application data structure. Perhaps one of the other regulars who does do GUI's will pick up the ball from here... --
From: Dave ba on 29 Mar 2010 12:57 well, even though it's not completely fixed right now, I must thank you for all your help and efforts. and I'll just keep searching and trying to get it right.
From: dpb on 29 Mar 2010 15:38 Dave ba wrote: > well, even though it's not completely fixed right now, I must thank you > for all your help and efforts. and I'll just keep searching and trying > to get it right. As I said, I've not used the GUI enough to be of any specific use, but I'm (at least pretty) sure the answer is in the section(s) I pointed out and the examples of using the data structure associated w/ the figure to retrieve what needs to be global data. --
From: Andrej on 29 Mar 2010 18:01 "Dave ba" <nummers123(a)hotmail.com> wrote in message <honkpa$20$1(a)fred.mathworks.com>... > Hi > We are going to use Matlab a lot at my school. And right now I’m making a program in it. > But I stumble on a problem. > Its like this: > > It is a video program, and you can click with the mouse on every frame to make a dot. > The coordinates of the dot are stored in two variables. > Zx and Zy (but I'll only use the Zy, here) > Then you can plot a graph in a axes to see the y-coordinate against the time(frames). > This is the code for the x-axes of the graph: > Code: > T = 1:1:number-of-frames-in-the-video; > > I create a variable here for the y-axes of the graph: > Code: > Y(number-of-frames-in-the-video, 1) = 0; > Y(the-current-frame-number, 1) = Zy; > > > Then the plot: > Code: > Plot(T, Y); > > This all works, but it only draws the dot of the current frame in the graph, and I want it to also > Draw the previous clicked dots. > But when the data of one dot is stored, and you click again the previous data is automatically erased because of the line: > Code: > Y(number-of-frames-in-the-video, 1) = 0; > > but I need the line to create the variable. > > Lets say the total number of frames is 5 > The Time variable would be: 1 2 3 4 5 > And the y-coordinates variable would be: > 0 0 0 0 0 > Then you click on the second frame, the y-coordinates variable could change in: > 0 34 0 0 0 > But then you click again on the third frame, it would change in: > 0 0 25 0 0 > Instead of, what I want: 0 34 25 0 0 > > So, if anyone knows how to fix this, it would help me a lot. Hello! I have a similar problem! My GUI reads data from serial port. The BytesAvailableFcn is set to execute callback function when terminator is read. In this callback function received data is displayed in the textbox and ploted in axis. Everything works fine but storing values of current data in array variable. My question is, when the array variable is resetting to zero? Is that every time the callback function is executed or when the GUI data is updated? Or somewhere else? Simply just can't find the solution! Please help! Thanks!
From: Dave ba on 30 Mar 2010 04:25
"Andrej " <kabumy(a)yahoo.com> wrote in message <hor7v1$cg4$1(a)fred.mathworks.com>... > My question is, when the array variable is resetting to zero? > Is that every time the callback function is executed or when the GUI data is updated? > Or somewhere else? in my case the code that resets the variable to zero is in the callback of the button that plots the graph, but this is also the place where the variable is created. In fact, its the same line. and I need to put it to zero to create it. but as I said before, putting that code on another place just creates a detour for it (to put it back to zero), you'll eventually have the same end results. that's how I see it at least.. then I thought, maybe I could use the IF statement to fix the problem. say that IF the variable has a value attached that isn't 0, then dont reset it. but then the code to create the variable still must not be repeated over and over again. so, is there a way to execute a piece of code only once in a program even though it comes back several times in the running of the program? |