Why won't my sinusoidal code display a plot?

조회 수: 3 (최근 30일)
Adriel Martinez-Alvarez
Adriel Martinez-Alvarez 2017년 2월 21일
댓글: KSSV 2017년 2월 21일
When I run the code, an empty plot displays. How do I make it display my sinusoids?
v = sqrt(2);
f = 2500;
t = 1/f;
time = [0:0.00001:2*t];
w = 2 * pi *f;
Vs = sin(w.*t);
Vc = v./2 *sin(w.*t+45);
Vl = v./2 * sin(2*t-45);
plot(time,Vs)
hold on
plot(time,Vc)
hold on
plot(time,Vl)
hold off
legend('Vs','Vc','Vl')
title('Plot for Question 5')
xlabel('Seconds')
ylabel('Volts')
grid on

채택된 답변

KSSV
KSSV 2017년 2월 21일
편집: KSSV 2017년 2월 21일
clc; clear all ;
v = sqrt(2);
f = 2500;
t = 1/f;
time = [0:0.00001:2*t];
w = 2 * pi *f;
Vs = sin(w.*time);
Vc = v./2 *sin(w.*time+45);
Vl = v./2 * sin(2*time-45);
plot(time,Vs)
hold on
plot(time,Vc)
hold on
plot(time,Vl)
hold off
legend('Vs','Vc','Vl')
title('Plot for Question 5')
xlabel('Seconds')
ylabel('Volts')
grid on
In Vs,Vc,Vl you are taking only one time step t. It should be a vector, time
  댓글 수: 2
Adriel Martinez-Alvarez
Adriel Martinez-Alvarez 2017년 2월 21일
Thank you! I didn't realize I was doing that, these late night pulls are killing me but I appreciate your rapid reply!
KSSV
KSSV 2017년 2월 21일
You are welcome....:)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by