I have tried to solve this problem by reading old questions and by googles help.
I writing a short script in matlab where the user types in a equation and then plot the data by using eval.
But I want to check if the equation is right and uses the right variables and so...
I have three variables, X,Y,Z with upper case, so for example 'X+Y-Z-7.5' is a solid equation, but 'XB-Z' isn't. Just 'X' is also a solid "equation"...
How can I write the expression? Here is what I have...
regexp(test,'(X|Y|Z)$|(X|Y|Z|\d)&&(+|-|*|/|)')
My next plan is to do like,
if regexp(test,'(X|Y|Z)$|(X|Y|Z|\d)&&(+|-|*|/|)') == 1
disp ('Correct')
end
So I want the regexp return if the string matches the whole expression, not just startindex. I have problem to fix that too.
Please, I'm stuck.