Plotting two functions that depend on boundary conditions.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two functions,
V_lamp_off(t)=Vs+(Voff-Vs)*y and V_lamp_on(t)=Vth+(Von-Vth)*exp(z). I want to plot V_lamp_off when the value is between 1 and 4 and plot V_lamp_on when the value is between 4 and 1. The length of the plot is driven by t. I can plot the two functions individually but want to show the shark tooth wave form. I've tried an if/then sequence with no luck.
if V_lamp_off <= Voff
then a = V_lamp_off;
elseif V_lamp_off >= Von
then a = V_lamp_on;
elseif V_lamp_on <= Voff
then a =V_lamp_off;
end
plot (t,a)
Any help would be appreciated.
1 commentaire
Réponse acceptée
madhan ravi
le 18 Nov 2018
Modifié(e) : madhan ravi
le 18 Nov 2018
"I want to plot V_lamp_off when the value is between 1 and 4 and plot "
Which value do you mean?
Instead of
if V_lamp_off <= Voff
then a = V_lamp_off;
elseif V_lamp_off >= Von
then a = V_lamp_on;
elseif V_lamp_on <= Voff
then a =V_lamp_off;
end
plot (t,a)
should be
a=ones(1,numel(t))
idx=(V_lamp_off <= Voff )
a(idx)=V_lamp_off(idx)
iddx=(V_lamp_off >= Von)
a(idx)=V_lamp_on(idx)
plot(t,a)
Plus de réponses (3)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!