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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -