I am trying to plot a function and its derivative using fplot.
fplot('3*x*sin(x) - 2*x', [-2*pi 2*pi], 'r')
This is working, But the command below is showing error.
fplot('diff(3*x*sin(x) - 2*x)', [-2*pi 2*pi], 'g')
Error Shown
??? Subscripted assignment dimension mismatch.
Error in ==> fplot at 105
x = xmin+minstep; y(2,:) = feval(fun,x,args{4:end});
Please give me some suggestions?
You could first calculate derivative, transform result in a string, and then plot obtained function:
Edit: @shoelzer provides correct explanation for the error you’ve received.