NAN answers problem in matrix
Show older comments
Hey everyone. I wanted to calculate the distance matrix of "L" but answers are all NANs.what is the problem?
sc=zeros(1000,72);
%% WT :
V_ci=4;
V_r= 12;
V_co=25;
Nwt=25;
Pwr=2*Nwt;
for i=1:1000
for c=1:24
m = [9.9,9.3667,9.1667,9,8.7,8.6,9,9.0333,9.3333,9.6,10.1333,10.2667,7.9667,8,8,7.7333,6.9667,5.9667,4.8333,4.4333,4.3333,4.1000,4.0667,4];
sigma = [0.7937,0.8021,0.8505,0.8185,0.755,1.0583,1.1533,1.1504,0.9504,1.1533,1.0066,0.8622,0.3786,0.4583,0.5,0.4509,0.2309,0.3786,0.3215,0.3215,0.4163,0.2646,0.2082,0.1732];
m_v=m(c);
sigma_v=sigma(c);
shape=(sigma_v/m_v)^(-1.086);
scale=m_v/gamma(1+1/shape);
sc(i,c)=wblrnd(scale,shape);
end
end
%% PV :
Npv=100000;
PF_pv=1;
for i=1:1000
for d=25:48
mu=[zeros(1,24),0,0,0,0,0.032,0.1278,0.2538,0.3824,0.4908,0.5680,0.6164,0.5990,0.5614,0.4672,0.3548,0.2228,0.1030,0,0,0,0,0,0,0];
sd=[zeros(1,24),0,0,0,0,0.0045,0.0406,0.0714,0.1189,0.1388,0.1659,0.1445,0.1175,0.0995,0.0788,0.0550,0.0410,0.0276,0,0,0,0,0,0,0];
mu_pv=mu(d);
sd_pv=sd(d);
beta=(1-mu_pv)*(mu_pv*(1-mu_pv)/sd_pv^2-1);
alfa=mu_pv*beta/(1-mu_pv);
sc(i,d)=betarnd(alfa,beta);
end
end
%% load
for i=1:1000
for f=49:72
sc(i,f)=0.9+0.2*betarnd(2,2);
end
end
M=zeros(1,72);
M = max(sc,[],1); % finding maximum array in each column
L=zeros(1000,72);
b=1;
for i=1:1000
for t=1:72
L(i,t)=sc(i,t)/M(b,t);
end
end
%% distance
N = size(L,1);
q(N,N) = 0;
for i = 1:(N-1)
X = ones((N-i),1)*L(i,:);
q((i+1):N,i) = sqrt( sum((X - L((i+1):N,:)).^2,2) );
end
D =q + q';
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!