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!