how can i plot positive magnitude only of a sine wave
96 views (last 30 days)
More Answers (1)
Sriram Tadavarty on 4 Aug 2020
From next time, please post the code you tried and where you have struck. So, that if one wants to try out the things, it helps to provide proper answer. Though you ask for plot of it, you haven't shown what is tried to plot for it.
I did take some possible values and tried to code what you are looking for.
A = 0.5;
F = 1000;
T = 0:1/(20*F):2/F;
Phase = 0;
DC_Voltage = ((A) * sin((2)*(pi*F).*(T)+(Phase)));
% time stamps of DC_Voltage
DC_Voltage_Negative_Idx = DC_Voltage < 0;
DC_Voltage(DC_Voltage_Negative_Idx) = 0;
% If you are not after the plot with T, then you can directly use plot(DC_Voltage(DC_Voltage >= 0))
Hope this helps.