Using the piecewise function and integration function with fplot
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
David Cole
am 31 Dez. 2023
Kommentiert: madhan ravi
am 1 Jan. 2024
How do I graph the three integral functions (V1,V2, &V3) below? I want to set the plot range for each of the three functions
%set up capacitor graph
V1 = (1/0.3e-9)*int(t*(5000/3),t); %Plot 0<t<3
V2 = (1/0.3e-9)*int(5e-3,t); %Plot 3<t<6
V3 = (1/0.3e-9)*int(-5000*t+35e-3,t); %Plot 6<t<7
cap_volt = [V1 V2 V3];
fplot(cap_volt,[0 7])
%fplot(capacitor_voltage_values,[0 7]) %fplot defaults to [-5 5] so need to change range
%xlim([0 7]) %set the x-axis to 7
%ylim([-80 30])
title('capacitor voltage')
subtitle('V_L(t = 6.5\mus) = -75V')
xlabel('time (\mus)') %\mu adds the micro symbol to the x-axis label
ylabel('voltage (V)')
grid on
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 31 Dez. 2023
syms t
%set up capacitor graph
V1 = (1/0.3e-9)*int(t*(5000/3),t); %Plot 0<t<3
V2 = (1/0.3e-9)*int(5e-3,t); %Plot 3<t<6
V3 = (1/0.3e-9)*int(-5000*t+35e-3,t); %Plot 6<t<7
cap_volt = [V1 V2 V3];
fplot(cap_volt,[0 7])
%fplot(capacitor_voltage_values,[0 7]) %fplot defaults to [-5 5] so need to change range
%xlim([0 7]) %set the x-axis to 7
%ylim([-80 30])
title('capacitor voltage')
subtitle('V_L(t = 6.5\mus) = -75V')
xlabel('time (\mus)') %\mu adds the micro symbol to the x-axis label
ylabel('voltage (V)')
grid on
1 Kommentar
madhan ravi
am 1 Jan. 2024
Looks like the OP forgot to copy paste the syms t. As the plot produced by your code is already posted by the OP.
Weitere Antworten (1)
Voss
am 31 Dez. 2023
syms t
%set up capacitor graph
V1 = (1/0.3e-9)*int(t*(5000/3),t); %Plot 0<t<3
V2 = (1/0.3e-9)*int(5e-3,t); %Plot 3<t<6
V3 = (1/0.3e-9)*int(-5000*t+35e-3,t); %Plot 6<t<7
cap_volt = piecewise(0<t & t<3, V1, 3<t & t<6, V2, 6<t & t<7, V3);
fplot(cap_volt,[0 7])
%fplot(capacitor_voltage_values,[0 7]) %fplot defaults to [-5 5] so need to change range
%xlim([0 7]) %set the x-axis to 7
%ylim([-80 30])
title('capacitor voltage')
subtitle('V_L(t = 6.5\mus) = -75V')
xlabel('time (\mus)') %\mu adds the micro symbol to the x-axis label
ylabel('voltage (V)')
grid on
2 Kommentare
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!