Plotting two functions that depend on boundary conditions.

1 回表示 (過去 30 日間)
SnukeN3
SnukeN3 2018 年 11 月 18 日
コメント済み: madhan ravi 2018 年 11 月 18 日
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 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 18 日
upload your full code with the required datas

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

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 18 日
編集済み: madhan ravi 2018 年 11 月 18 日
"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)

その他の回答 (3 件)

SnukeN3
SnukeN3 2018 年 11 月 18 日
clc, clear
%ECE 203-001 Team Project
format compact
% Part 2
Vs=6;
Von=4;
Voff=1;
t=0:0.001:40;
Rlamp=2.0E4;
R=2.32E5;
C=47E-6;
T=R*C;
x=-t/T;
y=exp(x);
V_lamp_off=Vs+(Voff-Vs)*y
% Part 3
Vth=Vs*(Rlamp/(R+Rlamp));
t0=R*C*log10((Voff-Vs)\(Von-Vs));
tc=t0+R*C*log10((Von-Vth)\(Voff-Vth));
z=-t/T;
V_lamp_on=Vth+(Von-Vth)*exp(z)
%Visualization
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)

SnukeN3
SnukeN3 2018 年 11 月 18 日
Closer, I think. The output wave from should have a log rising edge and an exponential falling edge, kind of a cool repeating shark fin. I'm getting a matrix full of ones and nothing on the graph

SnukeN3
SnukeN3 2018 年 11 月 18 日
Made a small change and I'm very close to the desired out put. I'll check my math. Thanks!
a=ones(size(t));
idx=(V_lamp_off <= Von )
a(idx)=V_lamp_off(idx )
idx=(V_lamp_on >= Von )
a(idx)=V_lamp_on(idx )
plot(t,a)

カテゴリ

Help Center および File ExchangeLabels and Styling についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by