How to plot two functions in one graph to demonstrate comparison

2 ビュー (過去 30 日間)
ALI DRIDI
ALI DRIDI 2020 年 8 月 8 日
コメント済み: dpb 2020 年 8 月 8 日
this is the private functions and the separated plotting for each, and i want to plot both of them under one graph. i couldnt do it
methods (Access = private)
function AcVoltage(app,Vrms,F,T)
AC_Voltage = ((Vrms) * sin((2)*(pi*F)*(T))); % this function is for input voltage sine wave demonstration
plot(app.UIAxes,AC_Voltage)
app.UIAxes.Title.String = 'AC Input Voltage';
app.UIAxes.YLabel.String = 'Vrms';
end
function Output_Voltage(app,Vdc,F,T)
DC_Voltage = ((Vdc) * sin((2)*(pi*F)*(T))); %testing the code NOT the Actual[for testing]
idx = DC_Voltage>=0;
plot(app.UIAxes,DC_Voltage(idx))
app.UIAxes.Title.String = 'Rectified DC Voltage';
app.UIAxes.YLabel.String = 'Vdc';
end
  3 件のコメント
ALI DRIDI
ALI DRIDI 2020 年 8 月 8 日
yes but it shows the DC_Voltage = ((Vdc) * sin((2)*(pi*F)*(T))); plotting g1raph only
dpb
dpb 2020 年 8 月 8 日
There's no "hold on" anywhere in the code -- both of those will plot the given data as new plot on the axes.
You need to create the axes, save the handle to it, set hold on to add plots to existing axis and then plot...With GUIS I don't know much ... to just plot you'd do something like
function plotStuff(app,Vrms,Vdc,F,T)
AcVoltage(app,Vrms,F,T)
hold(app.UIAxes,'on')
Output_Voltage(app,Vdc,F,T)
end

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by