Two different graphs!!! Difference between Pi and 3.14
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello i am a learner of matlab and i had a doubt
I have written a code to plot a cosine graph as followed
clear all
close all
t=-5:0.001:5;
y1=cos(2*pi*1000*t);
y2=cos(2*3.14*1000*t);
subplot(2,1,1);
plot(t,y1);
subplot(2,1,2);
plot(t,y2);
I have expected the same graph would be plotted for both the variables y and y1 in my code
but to my surprise i have got both of them different and i guess the first graph (i.e, y graph) must be correct and i dont know why the second graph has turned out as this
Please help me out in this...
Thanks in advance!!!
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 24 Sep 2013
We can explain this: the variation of t is
For the first case
v=2*pi*0.001*1000;
mod(v,pi)=0 % which means the cos will not change
For the second case
v=2*3.14*0.001*1000
mod(v,pi)
=3.1384
%which means the cos will change
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!