MATLAB: Limiting number of characters to three positions (ranging from 0–150)

charrangestrcmpstring

The code below limits number of characters to three positions ranging from 0 to 100.
if length(string) <= 1 || strcmp([string, char], '100')
string = [string, char];
end
However, if I try:
if length(string) <= 1 || strcmp([string, char], '150')
string = [string, char];
end
Number of characters are limited to two positions and range from 0 to 99.
If I try:
if length(string) <= 2 || strcmp([string, char], '150')
string = [string, char];
end
Number of characters are limited to three positions and range from 0 to 999.
I would like characters to be limited to three positions ranging from 0-150. Any suggestions? Thanks!

Best Answer

Or in
(string(1)=='1' & string(2) <='4')