Borrar filtros
Borrar filtros

Using the piecewise function and integration function with fplot

6 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 31 de Dic. de 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 comentario
madhan ravi
madhan ravi el 1 de En. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Voss
Voss el 31 de Dic. de 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 comentarios
Torsten
Torsten el 1 de En. de 2024
Better define cap_volt also for t=0, t=3, t=6 and t=7.
Voss
Voss el 1 de En. de 2024
I agree, but I'm doing what OP said he wanted.

Iniciar sesión para comentar.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by