How to fill the area under the curve in Matlab -


the user gives function, , make graphic in axis syms(x) , ezplot(funcion). , in case, user gives function , interval x. in second example, use plot() instead of ezplot(). here codes=

syms x;  funcion=eval(get(handles.txtfuncion, 'string'));  ezplot(funcion); 

the second code this:

a=eval(get(handles.txta, 'string'));  b=eval(get(handles.txtb, 'string'));  x=a:b;  funcion=eval(get(handles.txtfuncion, 'string'));  plot(x,funcion); 

i don't have symbolic math toolbox can address second code.

given sample data provided:

a = -10; b = 10; x = a:b; h.areaplot = area(x, eval('x.^2')); 

produces:

area plot

edit: alternatively can modify function input syntax work without needing eval:

a = str2double(get(handles.txta, 'string')); b = str2double(get(handles.txtb, 'string'));  x = a:b;  funcion = str2func(get(handles.txtfuncion, 'string'));  h.areaplot = area(x, funcion(x)); 

where text inputs take form '@(x) x.^2'


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -