[Matlab] Inline function and Macro?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
matlab inline-macro

Hi all,

I write a inline function.
Code:
%%---------
x=uint8(5);
bit=3;
% clear the bit
bitclr=inline('bitset(x,bit,0)');
c=bitclr(x,bit)
%%---------

But the output seems to be wrong.
Is there any other method to write something like C language's Micro?
And I want the inline function or Macro can be used by sub-function.
Thanks!

BTW, I use Matlab 5.3.
Any suggestions will be appreciated!
Best regards,
Davy
 

Type "bitclr" and you'll see the problem. Backwards argument order:
Code:
bitclr =
     Inline function:
     bitclr(bit,x) = bitset(x,bit,0)
From the MATLAB 7 help:
Code:
If inline does not return the desired function variables or if the function variables are in the wrong order, you can specify the desired variables explicitly with the inline argument list.

g = inline('sin(alpha*x)','x','alpha')

g =
     Inline function:
     g(x,alpha) = sin(alpha*x)
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…