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)

 Respuesta aceptada

Chunru
Chunru el 8 de Nov. de 2021
t=0:0.01:1;
y=10*sin(8*pi*t);
y(y<0) = 0;
plot(t, y)

3 comentarios

David Kenkadze
David Kenkadze el 8 de Nov. de 2021
y(y<0) = 0;
by this line you mean, that whenever y<0, y=0. rigt? I have never seen such syntax
Chunru
Chunru el 8 de Nov. de 2021
The is the logical index in matlab. You can also use y = max(y, 0) to do the same.
David Kenkadze
David Kenkadze el 8 de Nov. de 2021
thank you very much my friend

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 8 de Nov. de 2021

Comentada:

el 8 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by