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
3 ビュー (過去 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 で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!