MATLAB: PLOT COMMAND USING string arguments

plot

I have the following code if true
x = get(text1,'string');
y = get(text2,'string');
axes(plot1);
plot(x,y);
end
but I got and error :
ERROR using Plot invalid first data argument| | the string on text1 is -10:10 and the string in text2 is x.^2
What is wrong?

Best Answer

Maybe try
x = eval(get(text1,'string'));
y = eval(get(text2,'string'));
axes(plot1);
plot(x,y);