Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How do I write programming for this formula in MATLAB GUI ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Please help me :)
0 Kommentare
Antworten (1)
Image Analyst
am 17 Nov. 2016
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 Kommentare
Image Analyst
am 17 Nov. 2016
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
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!