Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How do I write programming for this formula in MATLAB GUI ?
조회 수: 2 (최근 30일)
이전 댓글 표시
Please help me :)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158108/image.png)
댓글 수: 0
답변 (1개)
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
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!