MATLAB: How to put a variable for a definput in prompt window

definputpromptwindow

Hello,
I have created a prompt window and for the definput I want to use a calculated variable. I tried to do it as cell array, double or string. Here is the code:
e.g
ExpRat0=12;
ExpRatdef=num2cell(ExpRat0);
prompt1=sprintf(['Expansion Ratio, ExpRat=']);
dlgtitle1= 'Nozzle Design';
dims1=[1 60];
definput1={ExpRatdef(1,1)}
answer_ExpRat=inputdlg(prompt1, dlgtitle1, dims1, definput1);

Best Answer

  • The default input must a be cell array of char vector
    ExpRat0=12;
    ExpRatdef=num2str(ExpRat0);
    prompt1=sprintf(['Expansion Ratio, ExpRat=']);
    dlgtitle1= 'Nozzle Design';
    dims1=[1 60];
    definput1={ExpRatdef}
    answer_ExpRat=inputdlg(prompt1, dlgtitle1, dims1, definput1);