plot half Wave rectied sindus

조회 수: 2 (최근 30일)
David Kenkadze
David Kenkadze 2021년 11월 8일
댓글: David Kenkadze 2021년 11월 8일
V(t)=10*sin(8*pi*t). I have to write a script, which will plot rectified Voltage on time scale.
error: __plt2vv__: vector lengths must match
t=0:0.01:1;
n=length(t);
j=10*sin(8*pi*t);
for i=1:1:n
if j>0
y(i)=j;
elseif j<0
y(i)=0;
end
end
plot(y,t)

채택된 답변

Chunru
Chunru 2021년 11월 8일
t=0:0.01:1;
y=10*sin(8*pi*t);
y(y<0) = 0;
plot(t, y)
  댓글 수: 3
Chunru
Chunru 2021년 11월 8일
The is the logical index in matlab. You can also use y = max(y, 0) to do the same.
David Kenkadze
David Kenkadze 2021년 11월 8일
thank you very much my friend

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by