- In the App Designer add "uieditfield" and "uibutton".
- Add a callback function to "uibutton". Below is the sample code snippet for the same:
How to load user input onto Matlab Web App Server
7 次查看(过去 30 天)
显示 更早的评论
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!');
0 个评论
采纳的回答
Animesh
2024-9-19
编辑:Animesh
2024-9-19
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:
% 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:
0 个评论
更多回答(1 个)
Taylor
2024-9-19
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Web App Server 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!