0

How to convert the cputime function to tic toc?

syms x
error = 0;
fun = 0; 
N = 10; 
b = 4; 
a = 0; 
f = (1+x)^(3/2);
f1 = @(y)(1+y)^(3/2);
t = cputime;
fun1 = double(int(f,x,a,b)); 
for N = 10:1000
    fun = 0;
    h = (b-a)/N;
    for i = 0:h:4-h
        fun = fun + (h/2)*(f1(i) + f1(i+h)); 
    end
    error = abs(fun1-fun); 
    if(error < 0.00001)
       break;
    end
end
t = cputime - t; 
fprintf('Approximate Value: %f\n',fun);
fprintf('N Value: %d\n',N);
fprintf('Computation time: %f\n',t);
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
  • 2
    Welcome to StackOverflow! What is your question? I see you're a new contributor, so I advise you to check out [How to ask a good question](https://stackoverflow.com/help/how-to-ask) and [How to create a minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Brian61354270 Apr 10 '20 at 00:53
  • So one issues : 1- I want Conversion of function cputime to function tic , toc . – – عبدالكريم المطيري Apr 10 '20 at 01:52
  • This is not a question, nor correctly formatted... – max Apr 10 '20 at 06:21
  • There are plenty of examples for usage in the documentation pages for both [`tic`](https://www.mathworks.com/help/matlab/ref/tic.html) and [`toc`](https://www.mathworks.com/help/matlab/ref/toc.html). Did you look at those? Did you run into difficulties getting it to work? – Cris Luengo Apr 10 '20 at 07:10

0 Answers0