Using the piecewise function and integration function with fplot

6 次查看(过去 30 天)
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
Unrecognized function or variable 't'.
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

采纳的回答

Walter Roberson
Walter Roberson 2023-12-31
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 个评论
madhan ravi
madhan ravi 2024-1-1
Looks like the OP forgot to copy paste the syms t. As the plot produced by your code is already posted by the OP.

请先登录,再进行评论。

更多回答(1 个)

Voss
Voss 2023-12-31
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

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by