Changeing the x Values when you plot the values

9 visualizzazioni (ultimi 30 giorni)
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')

Risposta accettata

Adam
Adam il 21 Mar 2017
Modificato: Adam il 21 Mar 2017
plot( n, s );
as shown clearly in
doc plot
except that 100:10:500 is 41 values rather than 40.

Più risposte (1)

ES
ES il 21 Mar 2017
Set axis limits and aspect ratios

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by