Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How do I write programming for this formula in MATLAB GUI ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Please help me :)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158108/image.png)
0 comentarios
Respuestas (1)
Image Analyst
el 17 de Nov. de 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 comentarios
Image Analyst
el 17 de Nov. de 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
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!