Is no graph???

2 Ansichten (letzte 30 Tage)
Khongsin Tinrach
Khongsin Tinrach am 3 Mai 2018
Bearbeitet: Stephen23 am 3 Mai 2018
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 Kommentar
Stephen23
Stephen23 am 3 Mai 2018
Bearbeitet: Stephen23 am 3 Mai 2018
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:

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy am 3 Mai 2018
Please use this.
x = 1 : 4*pi
y=sin(x)./cos(x);
plot(x,y);
  1 Kommentar
Khongsin Tinrach
Khongsin Tinrach am 3 Mai 2018
ok now I can do it.thank you

Melden Sie sich an, um zu kommentieren.


KSSV
KSSV am 3 Mai 2018
Bearbeitet: KSSV am 3 Mai 2018
It is very much working:
x = 1:0.005:4*pi ;
y =sin(x)./cos(x);
% y=tan(x) ;
plot(x,y);
  1 Kommentar
Khongsin Tinrach
Khongsin Tinrach am 3 Mai 2018
Is working.thank you very much.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by