필터 지우기
필터 지우기

Change values input dialog inputdlg defaults mid-script running

조회 수: 3 (최근 30일)
Pete
Pete 2014년 11월 17일
답변: Pete 2014년 11월 18일
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?)

채택된 답변

Pete
Pete 2014년 11월 18일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by