trying to index whole sine wave positively with time stamp
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Maadhav Akula
2020-8-18
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!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!