Need help with sprintf formatting

1 回表示 (過去 30 日間)
Jesse Randall
Jesse Randall 2017 年 7 月 18 日
コメント済み: Philip Borghesani 2017 年 7 月 18 日
So I have an sprintf statement in a for loop that looks like this:
run='4-QRSVH';
field='by';
files=21;
for f=1:files
fn=sprintf('./data/%s/%s%d.dat', run, field, (f-1)*10000 );
end
In the first loop the value of fn is './data/4-QRSVH/by0.dat' as it should be but then when the loop goes through the next iteration the last part is entirely messed up. It becomes an enormous string and I'm not sure how to fix it. Any suggestions?
  4 件のコメント
Jesse Randall
Jesse Randall 2017 年 7 月 18 日
Ahhhh I found the issue. I added a variable that already existed so it gets overwritten. Thanks for the reply!
Philip Borghesani
Philip Borghesani 2017 年 7 月 18 日
Doing that is usually a good clue that your script (or function) is getting too large and needs to be broken up.

サインインしてコメントする。

回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by