how do you plot graph sine

조회 수: 2 (최근 30일)
nur fazima
nur fazima 2022년 1월 8일
답변: Jeff Alderson 2022년 1월 8일
i need to plot graph using 10,25,50 and 100 points from v(t)=3 sin (2 pi.2000t). can anyone explain or teach me

채택된 답변

Image Analyst
Image Analyst 2022년 1월 8일
Try this. It should be pretty self-explanatory. Note in the first plot that, since it's not using enough points (sampling below the Nyquist frequency) you get aliasing, meaning the waveform does not have as many cycles as if you'd sampled it with enough points, like the 3rd and 4th plots.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 20;
% plot graph using 10,25,50 and 100 points
% from v(t)=3 sin (2 pi.2000t).
numPoints = [10, 25, 50, 100];
for k = 1 : length(numPoints)
% Get the number of points for this plot.
thisNumber = numPoints(k);
% Construct the t axis with this number of points.
t = linspace(0, 10, thisNumber);
% Compute v from t and the sin() function.
v = 3 * sin(2 * pi * t);
% Plot the result.
subplot(length(numPoints), 1, k); % New graph for this iteration.
plot(t, v, 'b.-', 'LineWidth', 2, 'MarkerSize', 18);
grid on;
caption = sprintf('Using %d points', thisNumber);
title(caption, 'FontSize',fontSize)
xlabel('t', 'FontSize',fontSize)
ylabel('v', 'FontSize',fontSize)
end
% Maximize window.
g = gcf;
g.WindowState = 'maximized'

추가 답변 (1개)

Jeff Alderson
Jeff Alderson 2022년 1월 8일
Please see this answer. While we can not assist in solving homework assignments for students, our self paced training and documentation is a great place for you to start.
https://www.mathworks.com/matlabcentral/answers/771408-how-do-you-plot-a-graph-of-the-sine-function?s_tid=answers_rc1-2_p2_MLT

커뮤니티

더 많은 답변 보기:  원격 교육 커뮤니티

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by