Left of Equals Sign not Valid for assignment?

Left of Equals Sign not Valid for assignment?

Post by D Nguye » Thu, 24 Sep 2009 01:26:02


Hello all,

For some reason I am getting the left of equals sign is not valid for assignment. I don't see why this may be so. I have a variable on the left and a value on the right. I know this error is common if you do something like "6 = c". However I am doing it the other way around but still get the error.

Here is the important portion of my code..

...
quotient = floor(number/26);
remainder = rem(26, number);

%set qLetter to an empty string
qLetter = '';

%if quotient is equal to 0, leave qLetter as it is
if(quotient == 0){
;
}
%if quotient is not equal to 0, convert quotient to the corresponding
%letter
else {
qLetter = int_to_letter(quotient);
}
end
...

I am getting the error after my first and only else, where I am assigning qLetter to another string.

Thanks all!
 
 
 

Left of Equals Sign not Valid for assignment?

Post by Wayne Kin » Thu, 24 Sep 2009 02:52:02


Hi, is int_to_letter() something you have written? why not num2str().

x = 1;
if (x==2)
sprintf('%d',x)

else
qLetter=num2str(x)

end

Wayne

 
 
 

Left of Equals Sign not Valid for assignment?

Post by Bruno Luon » Thu, 24 Sep 2009 02:54:02

Delete the curly brackets in your code. Matlab is not C.

Bruno