How can I put these subplots into a for loop?
Afficher commentaires plus anciens
Hello,
I've created these subplots which takes 300 seconds of data and chops it into 10 separate subplots of 30 second portions. I clearly did it manually here and I know there is a way to make it more efficient with a for loop, but i'm getting a bit confused on which values to choose to replace.
Thanks in advance for any and all help!
%% Load data
BR_file=dir('BRRAW*.mat');
load(BR_file.name);
%% Initialize
signal=[brraw.ecog, brraw.lfp]';
a=length(signal);
timex=[0:1/794:a/794];
timex(a+1)=[];
%% Subplots of 300 seconds of data chopped into 30 second portions
subplot(5,2,1)
time30=find(timex==30);
x=linspace(1,30);
hold on
plot(timex(1:time30),signal(1:time30));
subplot(5,2,2)
time60=find(timex==60);
x=linspace(30,60);
hold on
plot(timex(time30:time60),signal(time30:time60));
subplot(5,2,3)
time90=find(timex==90);
x=linspace(60,90);
hold on
plot(timex(time60:time90),signal(time60:time90));
subplot(5,2,4)
time120=find(timex==120);
x=linspace(90,120);
hold on
plot(timex(time90:time120),signal(time90:time120));
subplot(5,2,5)
time150=find(timex==150);
x=linspace(120,150);
hold on
plot(timex(time120:time150),signal(time120:time150));
subplot(5,2,6)
time180=find(timex==180);
x=linspace(150,180);
hold on
plot(timex(time150:time180),signal(time150:time180));
subplot(5,2,7)
time210=find(timex==210);
x=linspace(180,210);
hold on
plot(timex(time180:time210),signal(time180:time210));
subplot(5,2,8)
time240=find(timex==240);
x=linspace(210,240);
hold on
plot(timex(time210:time240),signal(time210:time240));
subplot(5,2,9)
time270=214381;
x=linspace(240,270);
hold on
plot(timex(time240:time270),signal(time240:time270));
set(gca,'Xlim',[240 270]);
subplot(5,2,10)
time300=find(timex==300);
x=linspace(270,300);
hold on
plot(timex(time270:time300),signal(time270:time300));
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Subplots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!