MATLAB: How to compare the values of different columns of the same matrix

columnsequalMATLABmatrix

I want to compare the values of the vector/matrix ZL with eachother. This is my code. It always displays false even if the values are equal
ZL=input('ZA ZB ZC ','s');
if ZL(1,1)==ZL(1,2)==ZL(1,3)
display('True')
else display ('false')
end

Best Answer

Basically, the function input with the argument 's' returns a char array (string), you need to convert it into vector of numbers, like this:
ZL=input('ZA ZB ZC ','s'); % this is returning a char array
ZL = sscanf(ZL,'%f')'; % add this line to break the char array into vector of numbers
% the transpose (') at the end is to get a row vector instead of column vector
if ZL(1,1)==ZL(1,2)==ZL(1,3)
display('True')
else display ('false')
end
Related Question