trying to index whole sine wave positively with time stamp

1 vue (au cours des 30 derniers jours)
ALI DRIDI
ALI DRIDI le 13 Août 2020
Hi, i was trying to plot the positive magnitude of the sine wave as a simulation for the rectified voltage the problem is when i use (idx) for plotting the positive magnitude i cant plot it with the time stamp even i used linsplace to equal the time variable (T = 0:(1/(100*F)):(10/F); ) with DC_Voltage=((Vdc) * sin((2)*(pi*F)*(T))); but an error shows to me that the input variables are not equal in length,below is the private function used:
function Output_Voltage(app,Vdc,F,T)
DC_Voltage = ((Vdc) * sin((2)*(pi*F)*(T)));
idx = DC_Voltage>=0;
plot(app.UIAxes,DC_Voltage(idx));
app.UIAxes.Title.String = 'Rectified DC Voltage';
hold(app.UIAxes,'off')
app.UIAxes.YLabel.String = 'Vdc';
end
---------------------------------------------------------------------------------------------------
this is the output that i get from plot(app.UIAxes,DC_Voltage(idx)); without time stamp, but when i do plot(app.UIAxes,T,DC_Voltage(idx)); I get the error message.

Réponses (1)

Maadhav Akula
Maadhav Akula le 18 Août 2020
Hi,
Both the inputs to plot function should be equal in length, so you can do the following to plot the Positive cycle of sine-wave:
plot(app.UIAxes,T(idx),DC_Voltage(idx));
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by