Can I repeat my calculations on different categories of data and just change the data source and variable name?
Show older comments
I got an experiment were the behavioural output is either to slow, fast or correct. I have 2 conditions (Auditory-Motor (AMC) and Motor-Only(MOC)) and have to decide between the use of the left or right hand.
I need to calculate the mean, std, correct means/std only, accuracy (amount and percentage).
I wrote a code that does all the calculations for the AMC condition for both hands and created a new matrix that would be 26 lines for each of the condition. I don't want to just copy-paste everything and change the condition by hand (would have to do it 5 times!), especially since I might want to change or add something later on and I do not want to always have to repeat the process.
Is there a fast and clean way to do so?
I named my Variables in this way: Condition_Subcondition_WhatToCalculate_ParticipantResponse (e.g. AMC_BothHands_Accuracy_N_FastOnly).
I want to write a code that would use the data called "AMC_MainData", runs through my code, then changes "AMC_MainData" to "AMC_LeftData" (in order to now use the data previously defined as the data of the left hand) and changes all the Variables beginning with "AMC_Both_" to "AMC_Left", then to "AMC_RightData" and "AMC_Right_", then to "MOC_MainData" and "MOC_Both" and so on.
Is there a way to do so?
1 Comment
Star Strider
on 14 Jul 2017
I’m not certain what you’re doing. Creating your code to be a function comes quickly to mind. Pass your data to your function, and have it return the results of its computations as output.
I’m not listing this as an Answer because I don’t have enough information to provide anything specific.
Answers (0)
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!