溶解图

Graph of dsolve

如何绘制以下函数?我需要 [0; 1].

的 x 个范围
syms y(x)
y(x) = dsolve(diff(y,x) == tan(x), y(0) == 1);
plot(y, [0 1]);

您收到的错误消息是:

Error using plot
Non-numeric data is not supported in 'Line'

这正是问题所在。 y 这里 不是数字数据 。相反,它是一种象征性的功能。您需要在所需的点评估 y,然后绘制它。

固定代码:

syms y(x)
y(x) = dsolve(diff(y,x) == tan(x), y(0) == 1);
x=0:0.01:1;
plot(x,y(x));

输出: