How to define correct my input variable?

1 次查看(过去 30 天)
Hi,
my base function is: function [out1,qc1,teststat,pval] = exceedence_correl(X,Y,qc)
I define X and Y ans x(:,1) and x(:,2), as the first column shows the returns on lets say equity index and second column returns on one of my commodity indices. The function then computes the exceedence correlation at different threshold levels (0,0.5,1,1.5).
As I have 10 different indices and I am interested in exceedence correlation between these indices. I wanted to know if there is a way to define my input data such that the function takes next indices pair after it is done computing the first one. So that I don't have to specify my X for each indices pair.
This is the way I have read in my data: data=xlsread('C:\Users\jkorolev\Documents\Thesis\Data\Bloomberg\Matlab asymmetric correlation.xlsx');
MSCISP500=data(:,[1 2]); MSCIGSCI=data(:,[1 3]); MSCIGSAG=data(:,[1 4]); MSCIGSEN=data(:,[1 5]); MSCIGSExEN=data(:,[1 6]); MSCIGSEM=data(:,[1 7]); MSCIGSIM=data(:,[1 8]); MSCIGSGold=data(:,[1 9]); MSCIGSLS=data(:,[1 10]);
So I want the function to go to the next pair, e.g. MSCIGSCI after it has calculated the exceedence correlation for MSCISP500, and still show me the outputs of the previous calculations. I do it for three time periods, so it is very time consuming to define the inputs one after another.
I am not sure if it is clear what I need or not. :(
Any help is appreciated.
Thanks, Julia
  1 个评论
dpb
dpb 2013-7-10
编辑:dpb 2013-7-14
IIUC, what you need is a for...end loop on the columns and use the data array indices to the data instead of copying it to new named variables.
If you want an id to go with the columns read it in or specify it but just use it as a label.
Example outline...
MATL
nCol = size(data,2); % no columns
results=zeros(nCol-1,4); % room for the four outputs each pair
for ix=1:nCol-1
results(ix,:) = exceedence_correl(data(:,1),data(:,ix+1),qc);
...
end
...
% display/use results here...

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by