How to load user input onto Matlab Web App Server

8 views (last 30 days)
With Matlab App designer, I used "inputdlg" to input space-separated values (e.g. 1 2 3) to upload an array of [1 2 3] to the program. However, when I push the APP to the web app server, it gives error message that inputdlg does not work with the web app server.
May you please suggest similar solutions where we could input space-separated values to upload an array into the web server app?
Below is the code that's runnable on App designer:
answer = inputdlg('Enter space-separated Parameters:','Modify Parameters', [1 50]);
app.modifiedParam = str2num(answer{1});
msgbox('Parameters are modified!');

Answers (2)

Taylor
Taylor on 19 Sep 2024
Functions that create dialog boxes that appear as a separate window are not supported in Web Apps. You could create a temporary edit field instead, or you could just have it hidden at first and revealed whenever you would have triggered the inputdlg command.

Animesh
Animesh on 19 Sep 2024
Edited: Animesh on 19 Sep 2024
In a web app created with MATLAB App Designer, "inputdlg" is not supported because it generates a modal dialog box, which is not compatible with the web environment.
Instead, you can use UI components available in App Designer such as "uieditfield" to achieve similar functionality.
You can try something like this:
  1. In the App Designer add "uieditfield" and "uibutton".
  2. Add a callback function to "uibutton". Below is the sample code snippet for the same:
% Here name of the uibutton component is SubmitButton
% and that of uieditfield is ParameterEditField
function SubmitButtonPushed(app, event)
% Get the text from the edit field
inputText = app.ParameterEditField.Value;
% Convert the space-separated string to a numeric array
app.modifiedParam = str2num(inputText); %#ok<ST2NM>
% Display a message box to confirm the parameters are modified
uialert(app.UIFigure, 'Parameters are modified!', 'Success');
end
The above approach uses the "Edit Field" to allow the user to input their space-separated values, and the "Button" to process this input when clicked.
You can refer the following documentation for better understanding of the above workflow:

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!