How can i copy .fig file in matlab ??

조회 수: 1 (최근 30일)
Pankaj Jha
Pankaj Jha 2019년 4월 14일
댓글: Adam 2019년 4월 16일
I want to save my A.fig and A.m file to another folder with the name B.fig and B.m file, and want the B.fig file work exactly as A.fig without doing any changes manually.
I tries to save using File>Save As >>
But when I run this B.fig file, the error dispalyed is "Undefined function 'A' for input arguments of type 'struct'."
B.fig is still mapped to A.m
How to fix this. ??
  댓글 수: 2
Pankaj Jha
Pankaj Jha 2019년 4월 14일
편집: Pankaj Jha 2019년 4월 14일
Error displayed is
Undefined function 'A' for input arguments of type 'struct'.
Error in @(hObject,eventdata)A('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Adam
Adam 2019년 4월 16일
What are your options set as in Tools -> GUI Options? Mine are always set to this:
16-04-2019 12-12-52.png
and using 'Save as' has always worked fine for me to replicate a GUI without any linkage between the new and old versions.

댓글을 달려면 로그인하십시오.

답변 (2개)

Geoff Hayes
Geoff Hayes 2019년 4월 14일
Pankaj - is A a GUI that you have created in GUIDE? Where are you calling File>Save As >> from? If I save the figure as a new file - from within the GUIDE GUI editor (not the m file editor) - then I am able to create a new figure and m file that has a new name and behaves as expected. And when I view the properties of my pushbutton callback (again from within the GUIDE GUI editor) I see that the callback has been updated correctly to refer to the new GUI name.
  댓글 수: 6
Pankaj Jha
Pankaj Jha 2019년 4월 16일
yes... sampl is same as A...
and I am also using R2014a... but the problem persists...
Geoff Hayes
Geoff Hayes 2019년 4월 16일
Can you attach A instead?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2019년 4월 14일
I do not know when the change was made, but in older GUIDE files, the callbacks were created as character vectors that set up the correct conditions and then called the appropriate function. At some point that changed to use anonymous functions to do the setup instead of character vectors. The above will only work with the ones coded as anonymous functions and not as character vectors.
In the case of GUIDE created GUI that are old enough that the .fig contains character vectors for the callbacks, then you encounter the problem that the character vectors are eval()'d outside of any function, and because of that, any function named in the character vector can only be found if it is a built-in or class method or is the first function in a .m or .p with the same name as the file. Thus in old enough GUIDE GUI, a callback coded as
'handles = guidata(gco); A(''A_pushbutton_Callback'', gco, [], handles)'
would not be able to find A unless there was an A.m .
In newer versions of GUIDE, anonymous functions are used instead of character vectors, and there is more potential for changing how anonymous functions resolve. I would, however, need to research in more detail to figure out how to make the change.
If you attach your A.m and A.fig then I will probe them to see if there is anything unusual in their structure (I wrote some tools to do that.)
One case where opening A in GUIDE and using Save As would not work, is the case where A itself was copied from a different fig .
  댓글 수: 3
Pankaj Jha
Pankaj Jha 2019년 4월 15일
PFA the files
Walter Roberson
Walter Roberson 2019년 4월 15일
Using guide to Save As worked for me (at least in R2019a)
I do not find anything unusual in the structure of your .fig or code.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by