Hi how do i plot a halfwave rectifier signal in matlab? i tried the coding below and only got the fullwave
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
zahrah S
le 24 Juin 2020
Réponse apportée : Gerardo Antonio López Partida
le 19 Déc 2020
>> f=50
f =
50
>> T=//f
T=//f
|
Error: Unexpected MATLAB operator.
>> T=1/f
T =
0.0200
>> l=linespace(0,10,100);
Undefined function or variable 'linespace'.
Did you mean:
>> l=linspace(0,10,100);
>> t=1:100;
>> sig=sin(2*pi*f*l*(t));
Error using *
Inner matrix dimensions must agree.
>> sig=sin(2*pi*f*l(t));
>> plot(t,sig);
0 commentaires
Réponse acceptée
Star Strider
le 24 Juin 2020
To rectify it, use logical indexing to eliminate the parts of the signal that are less than 0:
f=50;
t=linspace(0,30,500);
sig=sin(2*pi*f*t);
rect_sig = sig > 0; % Half-Wave Rectification
figure
plot(t(rect_sig), sig(rect_sig));
For full-wave rectification, use the abs() function.
4 commentaires
Plus de réponses (1)
Gerardo Antonio López Partida
le 19 Déc 2020
clc
clear all
close all
T=2*pi;%here you can change de period
t=0:T/1000:T;
f_t=sin(t).*(square(t,50));
plot(t,f_t,'r','linewidth',3);grid on;
0 commentaires
Voir également
Catégories
En savoir plus sur Semiconductors and Converters dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!