Changeing the x Values when you plot the values

9 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Uncertainty Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by