Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: undefined function or variable
Posted: Sep 17, 2013 10:31 AM

"JIAWEI " <jiaweihe.zju@gmail.com> wrote in message
news:l18bco\$3bd\$1@newscl01ah.mathworks.com...
> 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
slord@mathworks.com