Inadequate matrix size for sensitivity analysis
古いコメントを表示
Hi all,
I'm attempting to run an elasticity analysis on a matrix that's only 2 x 2:
syms AS JS Fe Pf
Svr = [AS JS Fe Pf];
mx = [0, AS*Fe*Pf;
JS, AS];
However, when I run the code with this matrix design, the results do not come out right. When I run the code with a matrix that's 4 x 4, however, the code does work. A colleague told me that there's some issues with the zeroes, but she didn't know how to fix it. Any advice?
Here is the portion of the code that's not working right:
realmx=subs(mx,Svr,meanvr);
[lambdas,lambda1,W,w,V,v]=eigenall(realmx);
meanlam1=lambda1; sensmx=v*w'/(v'*w);
elastmx=(sensmx.*realmx)/lambda1;
meansens = zeros(1,numvrs);
for xx = 1: numvrs
diffofvr=subs(diff(mx,Svr(xx)),Svr,meanvr);
meansens(xx) = sum(sum(sensmx.*diffofvr));
end;
meanelast=((meansens.*meanvr)/lambda1);
maxlams=zeros(1,numvrs);
for rate = 1:numvrs
vrates=meanvr; vrates(rate)=vrhi(rate);
realmx=subs(mx,Svr,vrates);
[lambdas,lambda1,W,w,V,v]=eigenall(realmx);
maxlams(rate)=lambda1;
end;
disp(Svr); disp(meanelast);
for vr=1:numvrs
x=sort(allelasts(:,vr));
CLup(vr)=x(1+round((reps-1)*0.975));
CLlo(vr)=x(1+round((reps-1)*0.025));
end;
disp(CLup); disp(CLlo);
The answer I get from that is:
meanelast = 0.8280 0.1720 0.1720 0.1720
CLup = 0.8291 0.3082 0.3082 0.3082
CLlo = 0.6918 0.1709 0.1709 0.1709
Which is erroneous because all elasticities should sum to 1. However, if I use a 4 x 4 matrix, I get elasticities that do sum to 1. Does anyone know how I might be able to fix this code so that the elasticities will process correctly with a 2 x 2 matrix?
Many, many thanks for taking the time to look at my issue!
2 件のコメント
Star Strider
2015 年 3 月 28 日
What is ‘eigenall’?
I can’t find it in the MATLAB documentation. Could it be the problem?
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!