How do I create subscript indicies to be real positive integers or logicals?
3 ビュー (過去 30 日間)
古いコメントを表示
I'm attempting to get data from a .nc file and when running this code I am getting the error of using real positive integers or logicals. Each variable produces exactly what is expected except for spei producing "NaN. The values that should be returned are decimals. How do I get them to return the decimal?
clear
clc
loc=xlsread('Tree_Ring_Data_WI_test.xlsx');%Load treering data only file. SiteNo. species column removed
year=loc(:,4); % formatting
lat=loc(:,2);%latitude
lon=loc(:,1);%longitude
[lonf,latf]=TransLatLon(lon,lat);%Function that translate lat and lon into coordination counts
files=dir('*.nc');%load Temperature files
for y=1:length(files);%Number of years in file
temp=ncread(files(y).name,'spei'); % variable name in climate file
%ind=find(year==y+1900);
%lont=lonf(ind);
%latt=latf(ind);
startm = 12 * (year - 1901)
spei = zeros(1,1380);
for i=1:length(lat);
for j=1:1382;
spei(j)=(temp(lonf(i),latf(i), (j + startm(i)));
end
end
6 件のコメント
Walter Roberson
2018 年 1 月 26 日
I suggest that at the command line you give the command
dbstop if error
and then run the code. When it stops, examine lonf(i) and latf(i) and startm(i)
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Large Files and Big Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!