function [ time,X,IsJs] = simulacionORdmJ(scaling_factors, BeatsSaved)
beats=501; CL=1000;
load('X0.mat')
model='endo';
time = cell(BeatsSaved,1); 
X = cell(BeatsSaved,1);
IsJs= cell(BeatsSaved,1);
options=[];
pos=1;
for n=1:beats
    if n <= beats-BeatsSaved
        [time_null, X_null]=ode15s(@ORdmD,[0 CL],X0,options,1,scaling_factors,model);
        X0=X_null(end,:);
    elseif n > beats-BeatsSaved
        [time{pos,1}, X{pos,1}]=ode15s(@ORdmD,[0 CL],X0,options,1,scaling_factors,model);
        X0=X{pos,1}(size(X{pos,1},1),:);
        pos=pos+1;
    end
end

for b=1:BeatsSaved
    for i=1:size(X{b},1)
        IsJs{b,1}(i,:) = ORdmD(time{b}(i),X{b}(i,:),0,scaling_factors,model);
    end
end
end