Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

RESAMPLING DATA FROM DIFFERENT EXCEL SHEETS

3 visualizaciones (últimos 30 días)
Dam
Dam el 24 de Mayo de 2018
Cerrada: Dam el 31 de Mayo de 2018
Good morning, i have an excel file (called Data) of 4 sheets and i try to:first randomly select a sheet then randomly select some value from it and repeat this 100 times each time taking a new random sheet and selecting random values form it(we can have the same sheet many times). Any idea about how to do this thank you in advance

Respuestas (1)

KSSV
KSSV el 24 de Mayo de 2018
Read about randperm. Every time randomperm gives you different number. To select a random sheet out of 4 sheets
sh = randperm(4,1) ;
You may follow the same to select data also.
  1 comentario
Dam
Dam el 24 de Mayo de 2018
thank you for your answer. i v read about randperm but not sure to know to what extent it can help as i want to randmly select a sheet out of 4 for 100 times. the problem is selecting different sheet each time out of the 100 times . my code gives me what i want for only one randomly selected sheet
if true
number_of_series=100;
a= (1:4);
rnd= randi(length(a));
market = xlsread('Data.xlsx',rnd);
R = market(:,2) ;% a serie of daily values of an index for 10 year
re=market(:,3);%the corresponding return series
Intrest=market(:,1);
rand= randi(2000,number_of_series,1);% randomly choose a number of starting points((ex:3 starting days))
x= zeros(252,number_of_series);
ret=zeros(251,number_of_series);
Int=zeros(252,number_of_series);
tc=0.01;
for k=1:number_of_series;
x(:,k) = R(rand(k):rand(k) + 251);
ret(:,k)=re(rand(k):rand(k) + 250);%and the corresponding returns
%ret2(:,k)=rett(rand(k):rand(k)+250); % returns for 1 year back.
Int(:,k)=Intrest(rand(k):rand(k) + 251);
rf=max( mean(Int))/100;
mea = mean(ret,1)*252;
sigma=std(ret,1)*sqrt(252);%input for choosing the market conditions
m(k)=mea(k); % mean return on stock index
meetCriteria = mea>-10&sigma<0.7;
out = ret(:, meetCriteria);
out2= x(:,meetCriteria);
r=Int(1,meetCriteria);
end
end

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by