Looping through a large questionnaire set, creating new tables

6 次查看(过去 30 天)
Hello!
I have a large questionnaire set consisting of 8 different questionnaires, with both written answers, likert-scale answers, multiple choice. Creating new tables for each of the questionnaires is easy enough. My problem is that for the likert-scale questions, the form system we used created new columns for each likert scale alternative- so for example- one of the questionnaires has 10 items where participants are to rate something on a scale of 1-7. So for 10 participants, ideally the output of the answers here should be a 10x10 table. I get a 10x70 table. The entire excel file is 10x881, which includes about 7 different questionnaires. I could go though the set and manually write down the answers in a new table, but seeing as we are going to have a lot of participants, I'm looking for a more effective solution.
I'm thinking of making a script that loops through my questionnaire set and creates a new table with the answers, but my matlab is real rusty. If anyone could give me some pointers on what I should do, I would really appreciate it.
The questions below involve two distinct aspects of your emotional life. One is your emotional experience, or what you feel like inside. The other is your emotional expression, or how you show your emotions in the way you talk, gesture, or behave. Although some of the following questions may seem similar to one another, they differ in important ways. Rate your answers on a scale of 1-7, from "strongly disagree" to "strongly agree"
When I want to feel more positive emotion (such as joy or amusement), I change what I am thinking about. *
This is my output. I don't want an individual column for each alternative, but rather all the answers in one column.
Any help or tips would be gratly appreciated!

采纳的回答

Jeff Miller
Jeff Miller 2020-1-8
I hate to say this, but it might be easiest to do a lot of the work in Excel.
Note that the data in your screenshot are represented as text in Excel (as indicated by the little triangle in the upper corner of each cell). To get around that problem, the first step (in Excel) is to make another set of corresponding columns with the actual numbers in them. Use the Excel 'Value' function for that. Note that the Value function will give you zero's as the numeric value for the empty cells, which is what you want for the next step.
Once you have the actual numeric values 1-7 in the set of corresponding new columns, simply make a new summary column which is the sum of the numbers in those 7 columns.
In Excel, you would have to do this manually for each item.
If you want to automate it in MATLAB, you can use the same general procedure. Use 'str2int' or 'str2num' instead of value to get the numeric values, and then you can either use sum or nanmean to get the summary column for each item. (Use sum if str2int gives 0's for empty cells, or nanmean if it gives nan's for empty cells.)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by