Including external file is making workspace messy
이전 댓글 표시
I have created a file named PLOT_STANDARDS.m put it in a folder and added that to path to include it in other files.
But when I include that file at the start of another script in the following manner:
%=================script begins here
clear; clc; close all;
% at the very beginning itself I include my file
PLOT_STANDARDS % this has lots of variables defined for easy access in any other script
%=============
% rest of the script goes here
My file PLOT_STANDARDS has a lot of variables which I have created to use as my defaults.
But including it in the above manner brings all those to the current workspace. This is very problematic as now I cannot find the variables of the current script easily. They get lost in the huge pile of variables that are imported from PLOT_STANDARDS.
I do not want to import specific variables from PLOT_STANDARDS instead I want to use any of the variable defined in there at will.
How to include PLOT_STANDARDS or access the variables in it in such a way that does not fill my workspace.
댓글 수: 3
Mathieu NOE
2021년 10월 8일
hi
I would suggest you create a structure with all PLOT_STANDARDS variables inside
then when you run your script it will load only one variable => this structure
you can access any indiidual variable from within this single structure
atharva aalok
2021년 10월 8일
Rik
2021년 10월 8일
You don't need to save your variables in a mat file, just store them in a struct. By having it be the output of your function you can even store it to a variable with a very short name. Typing s.var is not much more of a problem than typing var. Added bonus is that it is clear whether you are working with the loaded default or with a local copy.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!