"JIAWEI " <email@example.com> wrote in message news:firstname.lastname@example.org... > 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!