필터 지우기
필터 지우기

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