matlab - program isnt working because of an error in y -
this program, supposed input user starting x value, stepping value, , ending x value, user inputs y function likes, graph supposed graph keep getting error, ideas?
clear ; % clear memory close ; % close open figures drawnow ; % update screen clc ; % clear screen display('** welcome plotting program **') ; display(' '); start=input('please enter starting x value:'); step=input('please enter ending x value:'); stop=input('please enter step value:'); y= double(input('please input equation:')); x=double(start:step:stop); plot(x,y);
you can use str2func() convert string input function handle:
y = input('input rhs of equation function of ''x'' , enclose in '': ') y = str2func(['@(x)' y]); plot(x,y(x))
also note double(start:step:stop)
not work, since converting chars ascii mapping:
double('20') ans = 50 48
use instead str2double(input('...'))
Comments
Post a Comment