Plotting values without the zero values?

1 回表示 (過去 30 日間)
Douglas
Douglas 2017 年 2 月 18 日
回答済み: Walter Roberson 2017 年 2 月 18 日
Hi i am trying to calculate the time for solving Ax=b and the time it takes depending on the size of n x n matrices. But when i am plotting the graf the zero values in the array is plotted in the figure which makes the figure look like diffrent stapels instead of a line. Any suggestions i am so stuck. Thank you!
t = zeros(1,500);
for n = 100:10:500
A = rand(n,n);
b = rand(n,1);
tic;
x = A\b;
t(n) = toc;
end
plot(t)

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 2 月 18 日
I suggest that you use timeit().
Also in my experience the times can vary a fair bit, so I recommend using timeit in a loop to record multiple times at the same size

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by