How to plot the following function? I need x range of [0; 1]
.
syms y(x)
y(x) = dsolve(diff(y,x) == tan(x), y(0) == 1);
plot(y, [0 1]);
The error message that you get is:
Error using plot
Non-numeric data is not supported in 'Line'
This exactly tells what the problem is. y
is not numeric data here. Rather it is a symbolic function. You need to evaluate y
at the required points and then plot it.
Fixed Code:
syms y(x)
y(x) = dsolve(diff(y,x) == tan(x), y(0) == 1);
x=0:0.01:1;
plot(x,y(x));
Output: