What I'm trying to do is have my function proceed if certain conditions are met. And if a certain condition is met, then it toggles it into a state to go back and run the if statements again. I'm still learning matlab and I need to edit code for my research and don't know where to start. I am running most of my stuff through MGL. But the MGL part is slightly irrelevant to my question. I'm basically setting an experiment to do a certain task at a very specific moment in time. What I'm trying to do is create a randomized occurrence of this task (which I have already figured out) at set intervals that I created. What I want to do is have the IF statements toggle to whether or not they have occurred.
task{1}.parameter.tmstrigger = [0 1 2]; %trigger tms coil, 100ms, 250ms,400ms in that order
stimulus.initTime=mglGetSecs() %if you're not familiar with this, it's similar to the TIC/TOC function
stimulus.t2 = mglGetSecs(stimulus.initTime);variable = [0 1]; %this is what I'm unsure of
if task.thistrial.tmstrigger==0; %0.1ms
if stimulus.t2greaterequal10disp('check')
What I want to happen after this "disp('check')" is for the state of task.thistrial.tmstrigger==0; to toggle into a position that tells the program that it's already happened. After the task.thistrial.tmstrigger==0; I'm going to have a task.thistrial.tmstrigger==1; and a task.thistrial.tmstrigger==2 with very similar patterns. The format of what I'm trying to do is as follows (I just don't know how to write the code to do so):
task{1}.parameter.tmstrigger = 0; %[0 1 2]; %trigger tms coil, 100ms, 250ms,400ms in that order
Collect the time (which I already have with mglGetSecs) ...other code I didn't include in this post that's irrelevant... some sort of toggle variable?? if tmstrigger ==0 if stimulus.t2>= .10 %%%can I rewirete this as (if tmstrigger== 0 & stimulus.t2>=.1)?
disp('check') end SOMEHOW TOGGLE THIS TO SAY THE t2>.10 HAS HAPPENED AND NOT GO BACK TO THIS IF end if tmstrigger ==1 same format if tmstrigger ==2 same format
I really hope my question isn't too confusing. I'm a noob at matlab and still trying to understand the very basic logical stuff.
Thank you!
Best Answer