MATLAB: How can i use for loop in this function

for loopmatlab function

Hello! i was wondering if there is a way to grab every single value of a string input to do a validation.
for example, what I've got so far is:
function valid = Program05(num)
valid = 'false';
if length(num)>= 2
for i=num(1):num(end)
if num(1)=='+' || num(1)=='-'
if num(2)
end
valid = 'true';
else
valid ='false';
end
end
end
end
As you can see there, I'm stuck in the "if num(2)" because there is no limit for the string input and i don't know how to grab each value of the string to do the validation.
Thanks in advance.

Best Answer

for i = 1 : length(num)
this_char = num(i);
if this_char .....
end
end