How to save all variables in the matlab base workspace by a button in App?

조회 수: 5 (최근 30일)
Hello, I use "assignin" to write the variable created in App designer to the workspace, but I also manually type the code or formula in the command window to calculate, and thus create more variables.
I want to save all these variables in the workspace. I can use "save('C:\test.mat')" in the command window with no problem. I also have a save button in the app, which is supposed to do the same thing (save all variables in the matlab workspace).
With save('C:\test.mat') by the button, app designer will save all variables in both matlab workspace and the app desinger workspace, and then get a warning that Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects.
My question is how to save all these variables only in the matlab workspace?
Edit: matlab workspace means the base one

채택된 답변

Matt J
Matt J 2022년 12월 17일
편집: Matt J 2022년 12월 17일
It is not clear what you mean by, "the Matlab workspace". I will assume you mean the base workspace, i.e., the workspace of the command window. In your save button's callback, you would need,
str= "save('C:\test.mat')";
evalin('base',str)
  댓글 수: 2
Tianlun Yu
Tianlun Yu 2022년 12월 17일
Hello Matt, thank you for pointing out the correct name. Yes, I meant the base workspace of the command window, and you solved my problem.
Matt J
Matt J 2022년 12월 17일
You're welcome, but if it did solve your problem, please Accept-click the answer.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by