Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do I write programming for this formula in MATLAB GUI ?

1 回表示 (過去 30 日間)
nursuhailah suhaimi
nursuhailah suhaimi 2016 年 11 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Please help me :)

回答 (1 件)

Image Analyst
Image Analyst 2016 年 11 月 17 日
Try this
% Ask user for two floating point numbers.
defaultValue = {'2', '5'};
titleBar = 'Enter a value';
userPrompt = {'Enter Nmin : ', 'Enter Nmax: '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
% Convert to floating point from string.
Nmin = str2double(caUserInput{1})
Nmax = str2double(caUserInput{2})
% Check for a valid number.
if isnan(Nmin)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into Nmin.
Nmin = str2double(defaultValue{1});
message = sprintf('I said it had to be a number.\nTry replacing the user.\nI will use %.2f and continue.', Nmin);
uiwait(warndlg(message));
end
% Do the same for usersValue2
if isnan(Nmax)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into Nmin.
Nmax = str2double(defaultValue{1});
message = sprintf('I said it had to be a number.\nTry replacing the user.\nI will use %.2f and continue.', Nmin);
uiwait(warndlg(message));
end
% Do the same to get Pmax and Pmin......THEN................
totalRange = abs(Nmax - Nmin) * abs(Pmax - Pmin)
message = sprintf('Total Range = %f', totalRange);
uiwait(helpdlg(message));
  2 件のコメント
nursuhailah suhaimi
nursuhailah suhaimi 2016 年 11 月 17 日
THIS CODING IS VALID FOR MATLAB GUI ?
Image Analyst
Image Analyst 2016 年 11 月 17 日
Yes. It does a primitive GUI, with simple dialog boxes. It's not a full blown fancy GUI though. If you need something fancier, then try MAGIC: http://www.mathworks.com/matlabcentral/fileexchange/24224

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by