2017-02-01 45 views
-2

我想知道是否有人有任何洞察,为什么这两个剧情命令产生的数量级是不同的域?而y被评估并绘制 “谨慎”MATLAB:符号工具箱绘图与谨慎绘图

syms t 
x1Axis = 0:.01:10; 
fun1(t) = sin(t) 
plot(sin(x1Axis)) 
hold on 
y = sin(x1Axis) 
plot(x1Axis, y) 

fun1(t)绘制 “象征性”。我应该在第一个功能的情况下使用不同的绘图方法吗?

回答

2

不,你没有正确地绘制符号函数。

在您的代码中,指令plot(sin(x1Axis))不是符号图,而是正弦值与每个值的索引的数字图。

plot documentation page

plot(Y)创建在Y数据的2-d线图对的 每个值的索引。

  • 如果Y是矢量,则x轴刻度范围是1length(Y)

要绘制符号功能使用fplot

下面的例子将让你看到,无论是符号和数字地块是相同的:

xmin = 0; 
xmax = 10; 

% Symbolic Plot. 
syms t 
fun1(t) = sin(t); 
fplot(fun1, [xmin xmax], '-r'); 

hold on; 

% Numeric Plot. 
x = xmin:.01:xmax; 
y = sin(x); 
plot(x, y, '--g'); 

% Add legend. 
legend('Symbolic Plot', 'Numeric Plot', 'Location', 'north'); 

这是结果:

Sine: Symbolic and Numeric plot