简体   繁体   中英

plotting of matlab function

let us consider following picture

在此处输入图片说明

i wrote following code

>> t=-0.01:0.005:0.02;
>> y=cos(2*pi*100*t);
>> plot(t,y)

and got result

在此处输入图片说明

why it is so rough picture?also i have sampled it

>> t=0:Ts:0.02;
>> y=cos(2*pi*100*t);
>> plot(t,y)

i have got following picture

在此处输入图片说明

this seems ok,but about first one how can i make it more smooth?

You are plotting from -0.01 to 0.02 with a step of 0.005 , so that's only 7 data points. No wonder why your plot isn't smooth...

You need to refine your sampling by changing your 0.005 step to something much smaller. Start with 0.001 for example (that will give you 5 times more data points) and experiment until you are satisfied with the result:

t=-0.01:0.001:0.02;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM