How do I create subscript indicies to be real positive integers or logicals?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 26 Jan 2018
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)
Réponses (0)
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!