Is no graph???

2 次查看(过去 30 天)
Khongsin Tinrach
Khongsin Tinrach 2018-5-3
编辑: Stephen23 2018-5-3
I am new to matlab and I have some question.Why graph not come out.when I run this code
x = [1 : 0.005 : 4*pi]
y =sin(x)/cos(x);
plot(x,y);
But is work when I change y=sin(x)/cos(x) to y=tan(x) thank you for your answers
  1 个评论
Stephen23
Stephen23 2018-5-3
编辑:Stephen23 2018-5-3
Have a look at the size of y:
>> numel(x)
ans = 2314
>> numel(y)
ans = 1
You need to use element-wise rdivide:
sin(x) ./ cos(x)
^ you need this!
Read more about the differences here:

请先登录,再进行评论。

回答(2 个)

Yuvaraj Venkataswamy
Please use this.
x = 1 : 4*pi
y=sin(x)./cos(x);
plot(x,y);

KSSV
KSSV 2018-5-3
编辑:KSSV 2018-5-3
It is very much working:
x = 1:0.005:4*pi ;
y =sin(x)./cos(x);
% y=tan(x) ;
plot(x,y);

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by