Hi everyone. the following code is giving me an error, "Subscript indices must either be real positive integers or logicals" at line 16, please help me resolve it
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
siya lolo
le 3 Août 2018
Réponse apportée : Image Analyst
le 3 Août 2018
A = load('my_dates.txt'); for iLength = 1:56 if iLength < 10 label = sprintf('0%s',num2str(iLength)); else label=num2str(iLength); end {label} fn =sprintf('%s.txt',label); B =load(fn); [m n] = size(B); for ib = 1 : m n_date = B(ib); start_date = num2str(n_date); im = find(A == n_date); event_date = A(m-3:m+iLength+7); nm = length(event_date); for ie = 1:nm if ie < 10 event_label = sprintf('0%s',num2str(ie)); else event_label = num2str(ie); end n_event_date = event_date(ie); s_event_date = num2str(n_event_date); s_year = s_event_date(1:4); s_date = s_event_date(1:8); s_hour = s_event_date(9:10);
fn = sprintf('mslp_data/%s/mslp_%s_%s',s_year,s_date,s_hour);
MSLP = load(fn);
gn = sprintf('events1/%s/mslp_%s_%s',label,start_date,event_label);
dlmwrite(gn,MSLP)
end
end
end
0 commentaires
Réponse acceptée
Image Analyst
le 3 Août 2018
Since you forgot to attach 'my_dates.txt', about the best I can do is to refer you to the FAQ: https://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F , which has a thorough explanation of this error, and how to avoid/fix it.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!