why im not able plot graph in 1 sec window of 16 sample

조회 수: 10 (최근 30일)
germanbrain common
germanbrain common 2019년 8월 25일
댓글: Image Analyst 2019년 8월 27일
clc;clear all; close all;
A=1;
x=0:0.1:1;
sample=16;
y=A*sin((2*pi./sample)*x)
figure
plot(x,y)
untitled.jpg
  댓글 수: 4
dpb
dpb 2019년 8월 25일
x=linspace(0,1,16);
y=A*sin(2*pi*x);
plot(x,y)

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2019년 8월 25일
You didn't have anough points to see the sine wave so all you see is a traingle wave. Increase the number of points and use linspace():
numPoints = 50; % Whatever
Amplitude = 1;
t = linspace(0, 1, numPoints);
period = 0.4; % Seconds -- whatever you want;
y = Amplitude * sin((2*pi./period) * t)
plot(t, y, 'bo-', 'LineWidth', 2, 'MarkerSize', 9)
grid on;
xlabel('Time', 'FontSize', 13);
ylabel('Y', 'FontSize', 13);
title('Sine Wave', 'FontSize', 13);
0000 Screenshot.png
  댓글 수: 3
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 8월 27일
Change the period value, and see the results.
Image Analyst
Image Analyst 2019년 8월 27일
fs (omega) is (2*pi/period). For a 1 second, 1Hz chunk of signal, you'll have one wave of the sine wave. You can pick whatever sampling rate you want. Of course the higher it is, the more accurately you'll draw the signal.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by