computing matrix in for loop

2 views (last 30 days)
astronot
astronot on 29 Nov 2020
Edited: VBBV on 29 Nov 2020
hi friends ı want to calculate matrix of ZMN in for loop , it must have values like Z11,Z12,...Z55, but my code just calculate Z11 value . after that ı defined matrix as VM (1x5) and [VM] = [Z]*[IN] how can ı find IN matrix? How can ı do this ? ı hope you help me, ı desing this below code:
l=1;
a=0.001;
V=1;
delta=l/5;
for n = 1:5
for m = 1:5
dminus(m,n) = l-delta;
dplus(m,n) = l+ delta;
if (m==n) ZMN=2*log (delta+ (sqrt( a*a +delta*delta))/a);
elseif (2>= abs(m-n)) ZMN=log ( (dplus+ sqrt(dplus*dplus +a*a))/ (dminus +sqrt(dminus*dminus+a*a)));
else log(dplus/dminus);
end
end
end
A = [1.11*(10^-10),1.11*(10^-10),1.11*(10^-10),1.11*(10^-10),1.11*(10^-10)];
VM=A.';

Accepted Answer

VBBV
VBBV on 29 Nov 2020
l=1;
a=0.001;
V=1;
delta=l/5;
for n = 1:5
for m = 1:5
dminus(m,n) = l-delta;
dplus(m,n) = l+ delta;
if (m==n)
Z(m,n)=2*log (delta+ (sqrt( a*a +delta*delta))/a);
elseif (2>= abs(m-n))
Z(m,n)=log ( (dplus(m,n)+ sqrt(dplus(m,n)*dplus(m,n) +a*a))/ (dminus(m,n) +sqrt(dminus(m,n)*dminus(m,n)+a*a)));
else
Z(m,n) = log(dplus(m,n)/dminus(m,n));
end
end
end
  2 Comments
astronot
astronot on 29 Nov 2020
thank you can ı ask anthing else ? after that ı defined matrix as VM (1x5) and [VM] = [Z]*[IN] how can ı find IN matrix?
A = [1.11*(10^-10),1.11*(10^-10),1.11*(10^-10),1.11*(10^-10),1.11*(10^-10)];
VM=A.';
VBBV
VBBV on 29 Nov 2020
Edited: VBBV on 29 Nov 2020

Sign in to comment.

More Answers (0)

Categories

Find more on Spline Postprocessing 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!