How to plot the execution time for a Matlab code?

1 Ansicht (letzte 30 Tage)
nassima bekhoucha
nassima bekhoucha am 17 Mai 2020
Kommentiert: Walter Roberson am 17 Mai 2020
I have calculated the computation time of my simulation model by using 'tic & toc' instruction .now I want to show a graph of computational time. How can I plot that graph.
Thank you very much, any help is much appreciated
  2 Kommentare
Stanislao Pinzón
Stanislao Pinzón am 17 Mai 2020
I suppose you have some procedure between the instructions. For example, if a loop existed in that procedure one way would be.
tic;
A = [1 5 4 8 3];
T = zeros(length(A));
for i=1:length(A)
B = A(i)^2;
% Any procedure
T(i) = toc;
end
plot(T);
Walter Roberson
Walter Roberson am 17 Mai 2020
in the case where the time is dependent on the contents of A, use A as the x axes
for i=1:length(A)
tic;
b = inv(rand(A(i)) ;
T(i) = toc;
end
plot(A, T)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte


Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by