MATLAB Answers


Graphing a user input function between limits

Asked by David
on 8 May 2012

So what I'm trying to do is plot the user input function between the two plots (pltA and pltB) as number of times determined by the numberofplots input by user. With what I have now it does indeed calculate all the values of y and x between A and B for the default number of iterations (100) but when it plots them it only plots the first value and continues on with the program. Any ideas?

pltA = get(handles.txtA,'String');

pltA = str2num(pltA);

pltB = get(handles.txtB,'String');

pltB = str2num(pltB);

numberofplots = get(handles.txtPlot,'String');

numberofplots = str2num(numberofplots);

intIndex = (pltB - pltA) / numberofplots

intplotiteration = 1

strX = pltA

        while abs(intplotiteration) <= numberofplots
            strX = strX
            sngX = num2str(strX)
            sngX = ['(' sngX ')']
            strFx = strrep(strEquation,'x',sngX)
            sngPlot = eval(strFx)
            intIndex = pltA + intIndex
            intplotiteration = intplotiteration + 1
            hold all




No products are associated with this question.

0 Answers

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!