Building a survey GUI that records the answers of different study participants
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shaunak
el 29 de Jun. de 2024
Comentada: Shaunak
el 10 de Jul. de 2024
Hello everyone,
I'm pretty new to MATLAB and was hoping if I could get some advice. I'm trying to build a MATLAB GUI for a study where I want the participants to listen to multiple audio files and give ratings for each (by slider values). I plan on deploying a web app and making it available on the Web Server so that pariticipants (that don't have MATLAB) can access a link and send in their anonymous responses. I would like these responses to be saved in an excel sheet for all participants for analysis later.
I haven't reached the deployment stage of this GUI (currently waiting on a license for Web Server access), but I was wondering if anyone had any suggestions when it comes to building a participant survery in MATLAB. Additionally, if anyone has an pariticipant survey scripts that already do that, I would really appreciate it if you could share it with me!
0 comentarios
Respuesta aceptada
Ishaan Mehta
el 3 de Jul. de 2024
Hi Shaunak,
Creating a GUI for your application using MATLAB App Desinger should be a straight-forward process, using the UI components such as "Button" and "Slider", and employing their callback functions to execute relevant code.
I will try to give you a few pointers on the available MATLAB functions that could be of help in implementing this use-case:
1. You can use the "audioread" and "sound" functions to read an audio file and play it, as explained in the documentation below:
Read audio file: https://www.mathworks.com/help/matlab/ref/audioread.html
2. Ideally, you should save the survey responses in a "struct" object with fields {"participant_name", "audio1_rating", "audio2_rating", "audio3_rating"}, assuming you have 3 audio files to rate.
Then you can append the struct result for the current participant in an existing table of all the ratings received. The "struct2table" function can help with converting "struct" to a "table" which can then be appended to an existing table.
Same is illustrtated in the code snippet below:
% Button pushed function: SubmitButton
function SubmitButtonPushed(app, event)
% Collect the ratings and participant name
app.Ratings.participant_name = app.ParticipantName.Value;
app.Ratings.audio1_rating = app.RatingSlider1.Value;
app.Ratings.audio2_rating = app.RatingSlider2.Value;
app.Ratings.audio3_rating = app.RatingSlider3.Value;
% Convert struct to table
newEntry = struct2table(app.Ratings);
% Append to existing table
if isempty(app.RatingsTable)
app.RatingsTable = newEntry;
else
app.RatingsTable = [app.RatingsTable; newEntry];
end
% Save to Excel file
writetable(app.RatingsTable, 'SurveyResponses.xlsx');
end
This can be appended/modified with any other implementation to save the results in an online location, such as a REST server.
3. If you wish to send the response data to a REST server thorugh a POST request, the "webwrite" function can be helpful for the same.
I hope these pointers help you get started!
Más respuestas (1)
Umar
el 30 de Jun. de 2024
Hi Shaunak,
To answer your question, you can utilize the App Designer tool for a user-friendly interface. You can incorporate audio playback features and slider components for rating inputs. When deploying as a web app, consider using MATLAB Web App Server for hosting. To save responses to an Excel sheet, use MATLAB's writetable function to store participant data efficiently.
Here's a basic example to get you started:
% Sample code for saving participant responses to an Excel file
data = {'Participant 1', 'Rating 1'; 'Participant 2', 'Rating 2'};
T = cell2table(data, 'VariableNames', {'Participant', 'Rating'});
writetable(T, 'ParticipantResponses.xlsx');
Hope this will get you started.
3 comentarios
Umar
el 6 de Jul. de 2024
Hi Shaunak,
There are open-source alternatives available that offer similar functionalities. One popular open-source option is GUIDE (Graphical User Interface Development Environment), which is a part of Matlab itself and provides a more traditional approach to creating GUIs compared to App Designer.
For more information regarding GUIDE, please refer to
http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/creating_guis/devel_e2.html
Another notable open-source alternative is Qt Designer, which is part of the Qt framework. Qt Designer allows you to design GUIs visually and then export the UI to be used with various programming languages, including Python and C++. It offers a wide range of widgets and features for creating interactive applications.
For more information regarding Qt, please refer to https://doc.qt.io/qt-6/qtdesigner-manual.html
Now, if you prefer working with Python, Tkinter is a built-in GUI toolkit that comes with Python and allows you to create simple GUI applications. While Tkinter may not offer as many advanced features as Matlab's App Designer, it is a good option for basic GUI development.
For more information regarding tainted, please refer to https://docs.python.org/3/library/tkinter.html
Let me know if you still need further assistance or help.
Ver también
Categorías
Más información sobre Web Services en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!