Generate a plot of a sine wave having a 1 V amplitude and period of 0.01 seconds. voltage vs time. similar to picture.
currentky have: it does not plot as a voltage vs time.
x = linspace(0.01, 2*pi, 1500);
period = pi/4;
y = 1* sin(2 * pi * x / period);
plot(x, y, 'b-', 'LineWidth', 2);
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
title('y vs. x', 'FontSize', 20);
grid on;
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);

답변 (2개)

Walter Roberson
Walter Roberson 2020년 2월 13일

0 개 추천

xlabel('time (s)', 'FontSize', 20)
ylabel('voltage (V)', 'FontSize', 20)
title('Voltage vs time', 'FontSize', 20)
Now it plots voltage versus time.

댓글 수: 5

Lalo Vera
Lalo Vera 2020년 2월 14일
Hello, that is just a comment for my command in the axis. i need a command that outputs an expression of the sine wave in form of a frequency sine path.
%what you had
x = linspace(0.01, 2*pi, 1500);
period = pi/4;
y = 1* sin(2 * pi * x / period);
plot(x, y, 'b-', 'LineWidth', 2);
%what I add
xlabel('time (s)', 'FontSize', 20)
ylabel('voltage (V)', 'FontSize', 20)
title('Voltage vs time', 'FontSize', 20)
The result is voltage vs time.
What it is not is wavy the same way your example plot is. That is because you only construct a plain sine wave. You need to change the wave you generate in order to get something similar to the sample plot.
Hint: sine wave is always centered around 0. Therefore, in order to have something that is sine-like that is centered around a different value locally, you have to have added something to the sine wave. For example, you might have added a sine wave of a different frequency.
i need a command that outputs an expression of the sine wave in form of a frequency sine path.
Sorry, I do not understand that. "expression of the sine wave" seems like you are talking about a formula, but "in the form of a frequency sine path" seems like you are talking about a graph.
Lalo Vera
Lalo Vera 2020년 2월 14일
Pardon, a noisy signal into the code. the labeling its perfect.
Walter Roberson
Walter Roberson 2020년 2월 14일
What does my hint suggest to you?
How many full large periods does the signal have? Given the time period, what is the formula for a signal that behaves just that way?
How many small periods does the signal have? Given the time period, what is the formula for a signal that behaves just that way, as if it were not overlayed on a different signal?
Now how can you combine the two formulas ?
Lalo Vera
Lalo Vera 2020년 2월 14일
noisy_y = y + noiseAmplitude * rand(1, length(y)); ?

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

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2020년 2월 13일

댓글:

2020년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by