Why are my functions intefering with each other?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
For an assignment I have been set I have needed to make two functions. The first function plots a set amount of figures, this number of figures is determined by the input of the function, e.g function(X,8) uses data X to plot 8 separate figures. The second function I have made plots a linear regression model for two columns of the data given to me. When I call these functions in a .m file it seems that the first function is including the figure from the second function as one of its own figures. For example if I call function(X,8) and the linear regression function in the same .m file, 8 figures are made with the last one being the linear regression model, when in reality I want 8 figures from data X as well as the linear regression figure. I hope I have explained my situation adequately, does anyone know why this is happening???
Réponses (1)
Adam
le 3 Mar 2015
Are you creating a new figure for the linear regression model? If not then by default it will plot on the current figure which would, I assume, be the last of the 8 figures created by your first function.
You can explicitly number figures if you want too e.g.
figure(1);
figure(2);
...
figure(n);
although that also does not play well with two independent functions neither of which knows about the figure numbers created by the other so you are best off just creating a new figure as normal each time and keeping an array of the figure handles to use explicitly for any future instructions if required.
Cette question est clôturée.
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!