Answer solved by saving all variables (save function) at end of script, then loading (load function) at start. I also include the exist function as a test at the very start which looks for any saved file. If this is there, the used values are loaded, if not the default values are used. A rather useful input technique for dialog boxes.
Change values input dialog inputdlg defaults mid-script running
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi,
I've got an input dialog box for code, which works perfectly for input to script. What I'm looking to try is to have the code change the default values to the last values input, provided MatLab isn't closed. Code below:
Default = {num2str(632.8),num2str(100),num2str(100),num2str(3),num2str(256),num2str(1)};
Prompt = {'Wavelength (nm)','Focal length (mm)','% radius','Channel (R,G or B)','Max value (<256)','Type (1-4)'};
Title = 'FZP Generator User Input Parameters';
Answer = inputdlg(Prompt, Title, 1, Default);
So once the script is ran for the first time, and say the focal length is changed from 100 to 200, the next time the script is ran I'd like the displayed input (default) to read 200 so I don't have to change each time as this is likely to be similar for a setup. Then when MatLab is closed and reopened, the script defaults return to those set in the script (as above).
(I guess it's defining a [6x1] but how to overlook the absence of this the first time the script is run and then read from it when it exists?)
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!