Info

此问题已关闭。 请重新打开它进行编辑或回答。

RESAMPLING DATA FROM DIFFERENT EXCEL SHEETS

3 次查看(过去 30 天)
Dam
Dam 2018-5-24
关闭: Dam 2018-5-31
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

回答(1 个)

KSSV
KSSV 2018-5-24
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 个评论
Dam
Dam 2018-5-24
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

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by