How can I create a subplot from for loop with an if statement
    3 views (last 30 days)
  
       Show older comments
    
Hi All,
I have two threshold values  that I would like to run through my for loop, and subsequently plot each 'meanMUA' (for that threshold value)  as a subplot.
I attempted the following, but the 'meanMUA' for threshold1 is subplotted in both specified positions, rather than the 'meanMUA' for threshold1 (in position 1) and threshold2 (in position 2):
threshold1 = 0.018; 
threshold2 = 2*threshold1;
figure;
for threshold = 1:2
    for trial = 1:50
        for channel = 1:16
            for bin = 1:10000
                %%access data from bins, using sliding window
                bindata = absData(((bin*binWidth)+1-binWidth : bin*binWidth), channel, trial);
                if threshold == threshold1 || threshold == threshold2
                    %%calculate mua above threshold
                    mua(bin, channel, trial) = sum(bindata >= threshold);
                end
            end
        end
    end
meanMUA = (mean(mua,3)).';
subplot(1,2, threshold);
clims=[0 1];
imagesc(meanMUA,clims)
end  
Does anyone know how I can solve this? Your help is appreciated.
Thank you in advance.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!