storing variables in a table and retrieving them 1 by 1

1 回表示 (過去 30 日間)
abdul rehman
abdul rehman 2021 年 7 月 1 日
回答済み: Amit Bhowmick 2021 年 7 月 1 日
I want to store multiple values of letiude(lat1,lat2) and longitude (lon1,lon2) in a table and retrieving them 1 by 1 for following calculation
code:
lat1= 5.051099408347483; % latitude 1 5.03156496823464, 100.5242112313784
lat2= 5.031516767058222; % latitude 2 5.035615614086823, 100.52212496237453
lon1= 100.51424832033855 ; % longitude 1
lon2= 100.52419297410502 ; % longitude 2
R = 6371000; % metres
th1 = lat1 * pi/180; % φ, λ in radians
th2 = lat2 * pi/180; %
latch = (lat2-lat1) * pi/180;
lonch = (lon2-lon1) * pi/180;
a = sin(latch/2) * sin(latch/2) + cos(th1) * cos(th2) * sin(lonch/2) * sin(lonch/2);
c = 2 * atan2(sqrt(a), sqrt(1-a))
d = R * c %// in metres

回答 (1 件)

Amit Bhowmick
Amit Bhowmick 2021 年 7 月 1 日
use this,
Lat1=T.Lat(1) %T is the table name
Lat1=T.Lat(2)
To create table use,
Lat=[v1 v2 v3 v4]%Put valuea here
Long=[v1 v2 v3 v4]%Put valuea here
T=table(Lat,Long)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by