Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Execution Time

Subject: Execution Time

From: ASL Bravo

Date: 14 Mar, 2010 14:25:06

Message: 1 of 6

hii,

Does anyone help me to find the execution time of my code(shown below), also m a newbie, any help to modify or make this code compliant to MAAB guideline is appreciated.

function vehiclespeed = Calspeed(WSFrR,WSFrL,WSRrR,WSRrL,FrRQF,FrLQF,RrRQF,RrLQF)
%#eml
% This block supports an embeddable subset of the MATLAB language.
% See the help menu for details.

if FrRQF ==3
     FrR_QF = True;
else FrR_QF = False;
end;

if FrLQF ==3
     FrL_QF = True;
else FrL_QF = False;
end;

if RrRQF==3
     RrR_QF = True;
else RrR_QF = False;
end;

if RrLQF ==3
     RrL_QF = True;
else RrL_QF = False;
end;

if (FrR_QF && FrL_QF && RrR_QF && RrL_QF)
      a = [WSFrR,WSFrL,WSRrR,WSRrL];
      vehiclespeed = Avg(a);
   
      elseif (FrR_QF && FrL_QF && RrR_QF)
              b = [WSFrR,WSFrL,WSRrR];
              vehiclespeed = Avg(b);
      elseif (FrR_QF && FrL_QF && RrL_QF)
              b = [WSFrR,WSFrL,WSRrL];
              vehiclespeed = Avg(b);
      elseif (FrR_QF && FrL_QF && RrL_QF)
              b = [WSFrR,WSFrL,WSRrL];
              vehiclespeed = Avg(b);
      elseif (FrR_QF && RrR_QF && RrL_QF)
              b = [WSFrR,WSRrR,WSRrL];
              vehiclespeed = Avg(b);
              
      elseif (FrR_QF && FrL_QF)
              c = [WSFrR,WSFrL];
              vehiclespeed = Avg(c);
      elseif (FrR_QF && RrR_QF)
              c = [WSFrR,WSRrR];
              vehiclespeed = Avg(c);
      elseif (FrR_QF && RrL_QF)
              c = [WSFrR,WSRrL];
              vehiclespeed = Avg(c);
      elseif (FrL_QF && RrR_QF)
              c = [WSFrL,WSRrR];
              vehiclespeed = Avg(c);
      elseif (FrL_QF && RrL_QF)
              c = [WSFrL,WSRrL];
              vehiclespeed = Avg(c);
      elseif (RrR_QF && RrL_QF)
              c = [WSRrR,WSRrL];
              vehiclespeed = Avg(c);
      
      elseif (FrR_QF)
              vehiclespeed = WSFrR;
      elseif (FrL_QF)
              vehiclespeed = WSFrL;
      elseif (RrR_QF)
              vehiclespeed = WSRrR;
      elseif (RrL_QF)
              vehiclespeed = WSRrL;
      
      else
              vehiclespeed = 0;
end;

function AvgSpeed = Avg(q)
SpeedAscend = Sort(q);
AvgSpeed = (SpeedAscend(1)+SpeedAscend(2))/2;
  

Subject: Execution Time

From: Rune Allnor

Date: 14 Mar, 2010 14:37:47

Message: 2 of 6

On 14 Mar, 15:25, "ASL Bravo" <engr...@live.co.uk> wrote:
> hii,
>
> Does anyone help me to find the execution time of my code(shown below),

doc profile

Rune

Subject: Execution Time

From: Saurabh Mahapatra

Date: 14 Mar, 2010 18:18:06

Message: 3 of 6

Hi there,

Since this is an Embedded MATLAB function block, you need to use the Simulink Profiler to get an undestanding of the execution time in context of the othe blocks in your model:

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/f0-7640.html

Thanks,

Sauabh

Subject: Execution Time

From: ASL Bravo

Date: 16 Mar, 2010 23:17:05

Message: 4 of 6

Many thanks, can u pls advise of any pitfall in my code or better ways of coding it?

Appreciate your help!!

"Saurabh Mahapatra" <saurabh.mahapatra@mathworks.com> wrote in message <hnj98t$min$1@fred.mathworks.com>...
> Hi there,
>
> Since this is an Embedded MATLAB function block, you need to use the Simulink Profiler to get an undestanding of the execution time in context of the othe blocks in your model:
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/f0-7640.html
>
> Thanks,
>
> Sauabh

Subject: Execution Time

From: us

Date: 16 Mar, 2010 23:28:05

Message: 5 of 6

"ASL Bravo" <engr_uk@live.co.uk> wrote in message <hnp3hh$9h$1@fred.mathworks.com>...
> Many thanks, can u pls advise of any pitfall in my code or better ways of coding it?

well... did you even bother to look at what others have told you...

us

Subject: Execution Time

From: ASL Bravo

Date: 17 Mar, 2010 22:36:06

Message: 6 of 6

yeah I am not that lazy, it took 0.6% of total simulation time of entire simulink model. This function has been called 950 times, hence I wanna know if there is a better and faster implementation possible in embedded matlab. Any help...pls

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us