필터 지우기
필터 지우기

How to define correct my input variable?

조회 수: 2 (최근 30일)
Julia
Julia 2013년 7월 10일
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에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by