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:
Usage of Conditional Statements in Embedded Matlab Fucntion

Subject: Usage of Conditional Statements in Embedded Matlab Fucntion

From: niharika

Date: 24 Dec, 2012 12:34:13

Message: 1 of 2

HI
Can I know how to use both ifelse and switch statements in Embedded Matlab Function.

Subject: Usage of Conditional Statements in Embedded Matlab Fucntion

From: Thomas Clark

Date: 25 Dec, 2012 18:17:09

Message: 2 of 2

Same way as in normal MATLAB:

if var==1
   %some code
else
   %alternative code
end

switch a
   case 1
     % code
   case 2
      % code
   otherwise
      % code
end

Go here:
http://www.mathworks.co.uk/help/coder/index.html?s_tid=doc_12b
And click to open up the 'Algorithm Design' tab - it contains useful reference tables for what elements of the MATLAB language and what functions are supported. Both if/else statements and switch statements are supported in MATLAB code generation.




"niharika " <niharika.narayana@gmail.com> wrote in message <kb9i45$alm$1@newscl01ah.mathworks.com>...
> HI
> Can I know how to use both ifelse and switch statements in Embedded Matlab Function.

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