Undefined variable or function 'v'.

5 ビュー (過去 30 日間)
Nathan Zanetto
Nathan Zanetto 2015 年 10 月 7 日
回答済み: Adam 2015 年 10 月 7 日
I am trying to solve the following second order differential equation;
y'' = (-1/(RC))*y'-(1/(LC))*y
my function is as follows,
function dv = second_order_circuit(t,v)
R = 30;
C = 0.2;
L = 0.8;
dv(1) = v(2);
dv(2) = (-1/(R*C))*dv(1)-(-1/(L*C))*v(2);
end
I cannot figure out why I have the error
Undefined variable or function 'v'
Any help will be greatly appreciated, including what I will need in my command window to plot this over a 20 second period with and initial v(0) = 20 volts.
  1 件のコメント
Nathan Zanetto
Nathan Zanetto 2015 年 10 月 7 日
A simple restart of MatLab has solved the undefined variable issue, I am unable to produce anything though. What do I need in the command window? Thanks.

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

回答 (1 件)

Adam
Adam 2015 年 10 月 7 日
t = 1:10;
v = 17;
dv = second_order_circuit(t,v);
is an example of what you need on command line, although I have no idea what t and v are in terms of scalar, vector, 2d array, big numbers, small numbers, etc.

カテゴリ

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