フィルターのクリア

How to Plot(Time, Voltage) so that transient is captured for different inputs

8 ビュー (過去 30 日間)
James Perkins
James Perkins 2019 年 11 月 8 日
回答済み: ISIAKA SHUAIBU 2022 年 7 月 20 日
Hi, im working on some university coursework and am trying to do something with my plots. Id like someone to tell me if what im trying to do is possible, and if it is, how to do it?
The coursework is based on 2nd order ODE's. not using a numerical solver, I need to write a script which allows a user to input values for R, L & C, solves the 2nd order ODE, tells the user if the system is Under, Critically or Over damped and then plots voltage against time. (All of which i have already done).
My problem starts here; If the user is inputting different values each time, the plot will be different (voltage & time). the voltage on the Y axis automatically sets its own limits. However time along the x axis doesnt. This is because my voltage equation requires me to input time as a array.
Question: is it possible to write a script that changes the maximum point on the x axis (time) so that the graph captures the full transient?
See the attached figures, 'Good' shows the type of outcome im looking for, 'Bad' shows what im trying to stop happening when the user puts in different values to what i tested with.
  1 件のコメント
dpb
dpb 2019 年 11 月 9 日
How do you set what the transient time length is?
Just use xlim to set the range you want...altho we'd have to see how you're doing the plots to see why the autoscaling isn't working for both axes; normally would expect it to do it automagically.

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

採用された回答

Daniel M
Daniel M 2019 年 11 月 9 日
One possible idea is to use a multiple of the time constant for the circuit. For a parallel RLC circuit this is 2RC, and for series it is 2L/R. Try 4-5 times this amount and set the XLim of the axis. For example
[time,voltage] = ode45(odefun,tspan,v0); % etc, whatever your ode is.
tConst = 2*R*C; % assuming parallel
tMultiple = 4;
figure
plot(time,voltage)
set(ga,'XLim',[0 tMultiple*tConst])

その他の回答 (1 件)

ISIAKA SHUAIBU
ISIAKA SHUAIBU 2022 年 7 月 20 日
[time,voltage] = ode45(odefun,tspan,v0); % etc, whatever your ode is.
tConst = 2*R*C; % assuming parallel
tMultiple = 4;
figure
plot(time,voltage)
set(ga,'XLim',[0 tMultiple*tConst])

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by