Undefined Variable; Q7day, help! Thank you

10 ビュー (過去 30 日間)
Margaret Welsh
Margaret Welsh 2017 年 3 月 14 日
編集済み: James Tursa 2017 年 3 月 14 日
for i=st1_dates_vector(1) : st1_dates_vector(end);
st1_Q_year=st1_Q(st1_years==i);
for k=1:365-6;
Q7day=st1_Q_year(k:k+6)
st1_Q_7day_ave(k,ctr)=nanmean(Q7day)
end
end
min7_1=min(Q7day);

回答 (1 件)

James Tursa
James Tursa 2017 年 3 月 14 日
編集済み: James Tursa 2017 年 3 月 14 日
If you never get inside the for loop, Q7day will not get defined and that last line will error. Run your code in the debugger and step through your code line by line to see what path it takes and why it is skipping the line that defines Q7day.
To run your code in the debugger, first bring up the file in the editor. Then click on the dash next to a line number at the start of the code. Then push the green triangle run button. Then push the "step_by_line" button to execute each line (the button with the looping arrow on the left).

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by