Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: undefined function or variable
Replies: 2   Last Post: Sep 17, 2013 10:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,945
Registered: 12/7/04
Re: undefined function or variable
Posted: Sep 17, 2013 10:31 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"JIAWEI " <jiaweihe.zju@gmail.com> wrote in message
> Dear all,
> I am new to matlab and got stuck with a problem---- undefined function or
> variable b.
> could any of you help me with it? thank you very much.
> my function is as follows;
> function [ p ] = RT( a )
> %UNTITLED2 1-dimension rapid transformation
> % Detailed explanation goes here
> [m,n]=size(a);
> if n~=1
> for i=1:n/2
> b(i) = a(i) | a(i+n/2);

Assuming n is even, you could do this by converting a into a column vector,
reshaping that to have 2 columns and half as many rows, and ORing the two
columns. [You'd then want to make sure that b's orientation, row vector or
column vector, is what you want it to be.]

> c(i) = xor(a(i),~a(i+n/2));

Ditto but with XOR and NOT.

> end
> b=RT(b); c=RT(c);
> end
> p = [b,c];

If n is equal to 1 (i.e. you pass in a scalar or a column vector as a) then
your FOR loop never executes and neither b nor c are defined before this
line executes.

> end
> I have a feeling that the problem may be that b=RT(b) is not correct,but I
> am not sure and have no idea how to fix it. thank you again!

That's okay, if recursive.

Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.