matrix - Matlab: merging a new script with inbuilt code to compare the execution time -


please, have code determinant runs not display output time display. can gurus in house me out.

function determ=calll(a) a=input('rand()'); [rows, columns] = size(a); tic; if rows==2:size(a);     m11=a(2:end,2:end);         m1n=a(2:end,1:end-1);         mn1=a(1:end-1,2:end);         mnn=a(1:end-1,1:end-1);         m11nn=a(1:end-2,1:end-2);         deter=(m11)*(mnn)-((m1n)*(mn1));         determ=deter./deternew(m11nn);     end end toc disp('determinant =') 

the real issue that

  1. i want incorporate random matrix in code when run it, random matrix used me specify order of matrix because can not input 1000 1000 matrix manually.

  2. an inbuilt matlab code determinant should embedded in script.

  3. time of execution should included code , inbuilt matlab code.

  4. in all, when run program, should ask order (since random matrix must used) , compute determinant using code , inbuilt matlab code concurrently. note determinant of code , matlab same time of execution different. output after execution should in 2 forms

    • the value of determinant of script , time taken execution

    • the value of determinant of inbuilt matlab method , time taken execution.

@ebh

function out = thanksebh = input('matrix ='); [rows, columns] = size(a); n=100; t = zeros(n,1); k = 1:n end tic; out=1; = 1:rows     out = prod(a(i,i)*a(i,end)); end t(k,1) = toc; = 1:rows     out = prod(a(i,end-1)*a(end,i)); end t(k,2) = toc; t(k) = toc; 

i don't understand purpose of second code, far can guess try do, can suggest this:

function out = thanksebh n = input('matrix ='); = rand(n); n = 100; t = zeros(n,1); out = 1; k = 1:n     tic     % first procedure measure run-time     = 1:n         out = prod(a(i,i)*a(i,end));     end     t(k,1) = toc;     tic     % second procedure measure run-time     = 1:n         out = prod(a(i,end-1)*a(end,i));     end     t(k,2) = toc; end disp(mean(t)) end 

this measure execution time of 2 inner for loops separately , display mean of them. put inside inner for loops measured. note changed start of function (among other things) run.

please, if have other questions regarding this, ask them separately in different question.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -