フィルターのクリア

I am getting a bug in my code using fprintf, can someone tell me why?

1 回表示 (過去 30 日間)
Anuradha Bhattacharya
Anuradha Bhattacharya 2016 年 5 月 23 日
コメント済み: Walter Roberson 2016 年 5 月 23 日
This is my code:
a = load('xaxisfig7line1');
x = a(:,2);
y = a(:,1);
dy = diff(y)./diff(x);
b = [0];
dy = vertcat(b,dy);
X = horzcat(x,dy);
Y = horzcat(y,dy);
for i = 1:6614;
DY = abs(dy((i+1),1)-dy((i),1));
VALUE = abs(dy(i,1));
if DY>2000 & VALUE<1
fprintf('%f/n',x(i))
fprintf('%f/n',y(i))
else
end
end
The error I get is the printed numbers are showing DY and VALUE. Why is it not showing me x(i) and y(i)? Thanks...
  4 件のコメント
dpb
dpb 2016 年 5 月 23 日
I'm sorry, but the assertion "the printed numbers are showing DY and VALUE" is simply NOT so if the code actually being run is what is shown. Whatever value is being displayed by fprintf is the value of x, y at that time; that is definite. Now, those may not be what you think they should be, but Matlab isn't going to substitute some other value in their place. Use the debugger and see where things depart from your expectations.
A possibility is that as the earlier poster noted perhaps your if statement isn't being satisfied and you're not using the identical code as above and what you're actually seeing is the result of the lines defining DY and VALUE missing the trailing semi-colon. Something along these lines would be my best reading of the crystal ball...as the other responder noted, we can't see your terminal so with out a sample of the input data and the corresponding output it's all supposition.
Walter Roberson
Walter Roberson 2016 年 5 月 23 日
By the way you probably want \n not /n

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by