Error when using (plotting) one m file data into another m file.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
Here I'm facing a problem, I have four files: file A.m, file B.m, file C.m, and file D.m. And one more file to plot data which is plot.m, now at very start I putted all other files(A,B,C,and D) in the plot.m. However, some varibles are not appearing in the figure and error "undefine varible" appear when plotting. While most of the varibles are in file C and D, the file C appears okay but file D doesnot, and mysteriously when I change name position of file C and file D then both shows error that is (C.m D.m plots appers for C.m only and problem appears in D.m) then if change position and write like this way (D.m and C.m) then error occurs. Point to note here C.m and D.m also use A.m and B.m in the startd. Please if you know the solution.
7 commentaires
Réponses (1)
Adam Danz
le 1 Avr 2020
(Comment copied to answers section).
There could be several problems and if the same variable name is used in multiple scripts that could definitely cause a problem. This is why it's recommended to avoid using scripts unless all of the code is contained within a single script (even then, a function is better, IMO).
" I didn't clearly get your last point."
When you view the code from the editor, you should see orange squiggly lines under sections that contain warning messages. You'll also see an organe tick mark in the right margine and the square at the top of the right side is orange. If the problem would cause an error, the colors would be red instead of orange.
Notice the variable a is assigned a value twice, below.
When you hover over the orange squiggle line,
When you hover over the orange tick on the right,
0 commentaires
Voir également
Catégories
En savoir plus sur Function Creation 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!