- #1

JesseJC

- 49

- 0

Moved from a technical forum, so homework template missing

Hey guys, another question regarding MatLab here. In this assignment, I need to create a function of 'k' to count the number of floating point operations in the algorithm that I've made.

Here is my code so far:

expAk = zeros(1000, 1000);

load('CA3matrix.mat');

times = zeros(15, 1);

for j = 10:10:150

tic;

for k = 0:j

end

times(j/10) = toc;

end

plot(10:10:150, times);

figure()

imagesc(real(expAk));

colormap gray

I've bolded my algorithm. So our instructor told us to load the file 'CA3matrix' and do sort of an exponential series on it. I am trying to understand how I can count the number of flops for all of the runs, could I do this by hand? Is there an easy function to use? Can I create my own function? Any input would be great, thanks!

Here is my code so far:

expAk = zeros(1000, 1000);

load('CA3matrix.mat');

times = zeros(15, 1);

for j = 10:10:150

tic;

for k = 0:j

**expAk = expAk + (A^k)/(factorial(k));**end

times(j/10) = toc;

end

plot(10:10:150, times);

figure()

imagesc(real(expAk));

colormap gray

I've bolded my algorithm. So our instructor told us to load the file 'CA3matrix' and do sort of an exponential series on it. I am trying to understand how I can count the number of flops for all of the runs, could I do this by hand? Is there an easy function to use? Can I create my own function? Any input would be great, thanks!