Changeing the x Values when you plot the values

9 ビュー (過去 30 日間)
Douglas
Douglas 2017 年 3 月 21 日
編集済み: Adam 2017 年 3 月 21 日
Hi! I have a problem with plotting in the way it is supposed to be. I am supposed to plot the average time of solving a matrix with x = inv(A)*b;* When i plot the values of my function the x-values should go from "n=100:10:500". But when you store those values in a array the array will be filled with zeroes beacuse its storing in 100,110,120,,,etc. The elements in between will be zero, so when you plot the graph it also considers the zeroes as values. So i stored each value in an array to goes from 1-40 instead. Is there away to change the x of each element so that when i plot it, it will go from n=100-500?
Thank you for your time
t = zeros(1,200);
s = zeros(1,40);
r = 1;
for n = 100:10:500
for i = 1:1:200
A = rand(n,n);
b = rand(n,1);
tic;
x = inv(A)*b;
t(i) = toc;
end
s(r) = mean(t);
r = r + 1;
end
plot(s)
xlabel('Matrixes from 100 x 100 to 500 x 500')
ylabel('Averge solving time in seconds for x = inv(A)*b')

採用された回答

Adam
Adam 2017 年 3 月 21 日
編集済み: Adam 2017 年 3 月 21 日
plot( n, s );
as shown clearly in
doc plot
except that 100:10:500 is 41 values rather than 40.

その他の回答 (1 件)

ES
ES 2017 年 3 月 21 日
Set axis limits and aspect ratios

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by