I. data transmission problems there are many methods for data transmission, and there are also many related posts. I also referred to many posts when it comes to this item. Baidu can see a lot at a moment, if you don't give a link, I will introduce one of my most recommended methods: setappdata and getappdata function prototype is setappdata (figureHandle, varName, varValue)
I. data transmission problems there are many methods for data transmission, and there are also many related posts. I also referred to many posts when it comes to this item. Baidu can see a lot at a moment, if you don't give a link, I will introduce one of my most recommended methods: setappdata and getappdata function prototype is setappdata (figureHandle, 'varname', varValue)
I. Data Transmission Problems
There are many methods for data transmission, and there are also many related posts. I also referred to a lot of posts when it comes to this item. Baidu can see a lot at a moment and don't give a link, this section describes one of my most recommended methods:
Setappdata and getappdata
The function prototype is
Setappdata (figureHandle, 'varname', varValue)
It is used to set (or create) An application variable named varName on an image figureHandle and its value is varValue.
VarValue = getappdata (figureHandle, 'varname ')
The function is to retrieve the application variable named varName from an image figureHandle, and its return value is stored in varValue.
Where
FigureHandle is a graphical object handle. Generally, the main window of the GUI program is a graphical object handle. handles. figureTag is used to reference the main window object in the GUI program. figureTag is the tag attribute value of the main window.
The name of the application variable on varName figureHandle can be different from the name of the variable written by the program. In the above function prototype, note ''to remind you that the variable name must be of the string type.
VarValue setappdata indicates the variable to be saved, which can be of any type. getappdata indicates the variable used to save the retrieved value.
|
TIPS: it is best to use setappdata (0, 'varname', varValue) in a multi-window GUI program to save variables (if not created, it will be automatically created ).
VarValue = getappdata (0, 'varname ')
To obtain the saved variables (if not saved, [] is returned, that is, null). '0' is the root object, the advantage of this is that it can be called between different windows (not only between different functions of the same window), and you do not need to consider which object is saved, no error even after gcf Transformation
In addition, you may find that the figureHandle I introduced is a graphical object handle, and other object handles are also acceptable, but this is used relatively more |
Data is transmitted between functions and between windows through storage and retrieval. EG:
Function 1
Setappdata (handles. mainFigure, 'matrixa ',)
Function 2
B = getappdata (handles. mainFigure, 'matrixa ')
In this way, I pass the value of A to B.
In addition, develop a good habit, especially when you are using the root object to store variables, remember to delete these variables after use
Rmappdata (figureHandle, 'varname ')
Ii. Window exclusive
In fact, this problem is very simple, but it was too long to search at that time, and I did not point to the question, so I still listed it.
You can set the windowstyle attribute value to 'modal' when creating a window (set is also used to complete the setting of this attribute)
3. Run the. EXE program in MATLAB
The method to run the executable program in MATLAB is to add one in front !, For example :! Picshow. The suffix is optional.
| TIPS: All characters in MATLAB (except ''and comments) are input in English, especially punctuation marks, which are easy to be mistaken. |
Iv. Matrix
MATLAB's matrix calculation is extremely convenient, but it should be used with caution in tedious programs. If operations on the Matrix need to be performed multiple times, but only a small number of elements in the matrix are actually performed, we recommend that you use element operations instead of matrix operations, which is much more efficient, I personally experienced that slow, so I cannot stand it.
In fact, there are still many tips. You are welcome to point out the author's mistakes. I hope that you can leave some of your experience in using MATLAB in your comments ~~~~