MATLAB: I want to use the data input by the user in the inputdlg for calculation, how can i do this?

inputdlg

my code is like this
prompt = {'CompoundName','Temperature'};
dlg_title = 'Input';
num_lines = 1;
CompoundName = inputdlg(prompt,dlg_title, num_lines);
C1=126.1
C2=183
C3=77
C4=0
V=C1*T^C2/1+C3/T+C4/T^2;
if strcmp(CompoundName, 'Acetaldehyde')
fprintf=('viscosity: %d',V);
end

Best Answer

Change line
fprintf=('viscosity: %d',V);
to
fprintf('viscosity: %d\n',V);
prompt = {'CompoundName','Temperature'};
dlg_title = 'Input';
num_lines = 1;
CompoundName = inputdlg(prompt,dlg_title, num_lines);
T = str2num(CompoundName{2}) ;
C1=126.1 ;
C2=183 ;
C3=77 ;
C4=0 ;
V=C1*T^C2/1+C3/T+C4/T^2;
if strcmp(CompoundName, 'Acetaldehyde')
fprintf('viscosity: %d',V);
end