How to define correct my input variable?

1 view (last 30 days)
Julia
Julia on 10 Jul 2013
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 Comment
dpb
dpb on 10 Jul 2013
Edited: dpb on 14 Jul 2013
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...

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!