Matlab code runs sometimes and sometimes does not
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I have written a matlab script that calls multiple user-defined functions for various computations. I create figure objects within the main script, then some of the user-defined functions plot in the existing figure object (used proper hold on and off so that different functions plot on the same figure as needed). However, sometimes the script runs, creates all figures correctly with all the information but I keep getting busy prompt in matlab and the variables and matrices in the main script do not get populated in the workspace. Only by stopping the main script, I get the workspace filled up. Then sometimes when I clc, clear all, close all and re-run the script I get all figures and all variables and matrices defined in the main script correctly without delay. The whole process is more consistent when I don't plot any figure (The script always runs and workspace gets filled). Any idea for this kind of behavior (sometimes runs, next time might)?
2 commentaires
DGM
le 8 Fév 2023
Sounds to me more like something is causing a prolonged delay rather than it simply not running. Whether that's caused by the script or not is something that can't really be known without seeing the script.
Using clear all instead of clearvars is typically not necessary and can lead to slowdowns
... though I'm not sure if that command is normally part of your script.
Depending on how graphics objects are created, it's possible to have race conditions that may be caused by an object not existing before it's existence is required. The consequences of such a scenario depends entirely on what the code is doing.
Réponses (0)
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!