I get an error in the loop

1 view (last 30 days)
Muhendisleksi
Muhendisleksi on 29 Mar 2017
Commented: Muhendisleksi on 30 Mar 2017
K=[27 27320.5963 4223312.4563
32 25496.3840 4221760.5030
34 28874.9170 4221756.7649
39 27284.2609 4220235.3943
133 26812.2676 4221811.7328]
olc=[0.00000
70.76351
105.09584
0.00000
42.40162
89.83755
0.00000
50.28006
98.61182
0
36.51504
106.45528
0
80.90273
160.68555
276.73136]
dn=[27;27;27;32;32;32;34;34;34;39;39;39;133;133;133;133]
bn=[34;133;32;27;133;39;39;133;27;32;133;34;27;34;39;32]
dog_olc=[dn bn olc]
R=6373394
for i = 1:length(dog_olc)
dn=dog_olc(i,1); bn=dog_olc(i,2); olc=dog_olc(i,3);
xi=K(find(K(:,1)==dn,2)); yi=K(find(K(:,1)==dn,3));
xk=K(find(K(:,1)==bn,2)); yk=K(find(K(:,1)==bn,3));
dt=((-200/pi)/(6*R^2))*((xk-xi)*(2*yi+yk));
Dog_olc(i)=dog_olc(3,i)+dt
end
There are results visually. I do not succeed in getting these results.

Accepted Answer

KSSV
KSSV on 30 Mar 2017
clc; clear all ;
K=[27 27320.5963 4223312.4563
32 25496.3840 4221760.5030
34 28874.9170 4221756.7649
39 27284.2609 4220235.3943
133 26812.2676 4221811.7328] ;
olc=[0.00000
70.76351
105.09584
0.00000
42.40162
89.83755
0.00000
50.28006
98.61182
0
36.51504
106.45528
0
80.90273
160.68555
276.73136] ;
dn=[27;27;27;32;32;32;34;34;34;39;39;39;133;133;133;133] ;
bn=[34;133;32;27;133;39;39;133;27;32;133;34;27;34;39;32] ;
dog_olc=[dn bn olc] ;
N = size(dog_olc,1) ;
R=6373394 ;
Dog_olc = zeros(N,1) ;
for i = 1:N
dn=dog_olc(i,1); bn=dog_olc(i,2); olc=dog_olc(i,3);
xi=K(find(K(:,1)==dn,2)); yi=K(find(K(:,1)==dn,3));
xk=K(find(K(:,1)==bn,2)); yk=K(find(K(:,1)==bn,3));
dt=((-200/pi)/(6*R^2))*((xk-xi)*(2*yi+yk));
Dog_olc(i)=dog_olc(i,3)+dt ;
end
Dog_olc
  4 Comments
Muhendisleksi
Muhendisleksi on 30 Mar 2017
Edited: Muhendisleksi on 30 Mar 2017
dt(1,1)= ((-200/pi*10000)/(6*R^2))*((4221756.7650-4223312.4563)*(2*27320.5963+28874.917))
Dog_olc(1,1)=0.339375914157676
This should be the process.
Muhendisleksi
Muhendisleksi on 30 Mar 2017
I saw my mistake! thank you very, very much.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!