I am trying to generate a 2D matrix for the geographical Longitude and Latitude, for the ranges below:
Φ = [0,Δφ,2Δφ, ..., 179Δφ] Θ = [0,Δθ,2Δθ, ..., 287Δθ] . I tried this
long=linspace(0,360,288); lat=linspace(0,180,180); res=zeros(288,180); for i=0:1.25:length(long) for lat=0:1:length(long) res(long,lat)=[long lat]; end end but I got this error
Subscript indices must either be real positive integers or logicals.
Error in odayalbedo (line 12) res(long,lat)=[long lat];
Any suggestions??? Thanks in advance

댓글 수: 1

Oday Shahadh
Oday Shahadh 2017년 2월 6일
편집: KSSV 2017년 2월 6일
Sorry I made a mistake when copying the code
long=linspace(0,360,288);
lat=linspace(0,180,180);
res=zeros(288,180);
for i=1:1.25:length(long)
for j=1:1:length(long)
res(i,j)=[long(i) lat(j)];
end
end
and I got this error
Subscripted assignment dimension mismatch.
Error in odayalbedo (line 12) res(i,j)=[long(i) lat(j)];
Thanks

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2017년 2월 6일

1 개 추천

Are you looking for this?
M = 288 ; N = 180 ;
long=linspace(0,360,M);
lat=linspace(0,180,N);
[Long,Lat] = meshgrid(long,lat) ;
You cannot save [long(i) lat(j)] into res(i,j). res(i,j) needs a single number and [long(i) lat(j)] are two numbers. Else there should be some other relation between long and lat.

댓글 수: 2

why I got the size :
size([Long,Lat])
ans =
180 576
KSSV
KSSV 2017년 2월 6일
[Long,Lat] this joins Long, Lat matrices of each size 180x288 to size 180x576.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

질문:

2017년 2월 6일

댓글:

2017년 2월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by