(Probably elementary) Plotting problem

I have some problem with plotting.
Basically I have a vector
a=1:0.2:10
for n=1:1:length(a)
while ... %a bunch of calculations using a(n)
b(n)=b(n)+1
end
end
I want to plot b against a, so I wrote
plot(a,b)
but it doesn't plot the results I got by entering values individually-- when I didn't have the outer for loop . Could somebody please help?
Thank you.

3 件のコメント

per isakson
per isakson 2012 年 4 月 16 日
Looks ok to me. Any error message? Preallocate b = nan(size(a)). The size of a and b?
Richard
Richard 2012 年 4 月 16 日
@per isakson: There isn't an error message. It plots something, but not the right thing...
per isakson
per isakson 2012 年 4 月 16 日
@Richard: Put the code in a function and debug your code. Set a break point on the first line and step line by line. Check the values. The problem is hardly with the plot command. Try plot(a,b,'.').

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

タグ

質問済み:

2012 年 4 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by