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 (최근 30일)
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

채택된 답변

Image Analyst
Image Analyst 2018년 8월 3일
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개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by