필터 지우기
필터 지우기

Save the Values of Variable in a Function to Workspace.

조회 수: 2 (최근 30일)
Nitish Katal
Nitish Katal 2018년 5월 17일
답변: kausalya lakshmanan 2018년 5월 17일
We need to save the value of vector u in the Workspace
I have the following code, the Function is
function dx = ex3(t,x)
A1=[0 1;17.2941 0];
A2=[0 1;11.0073 0];
B1=[0;-0.1765];
B2=[0;-0.1763];
k1=[-435.7417 -61.7943];
k2=[-400.5752 -61.8642];
mid = [-pi/2 pi/2];
mu1 = tmf(x(1),mid(1),0,mid(2));
mu2 = 1-mu1;
zeta1 = mu1/(mu1 + mu2);
zeta2 = mu2/(mu1 + mu2);
A = (zeta1 * A1 + zeta2 * A2);
b = (zeta1 * B1 + zeta2 * B2);
k = (zeta1 * k1 + zeta2 * k2);
u =-k*x
dx = A*x+b*u;
end
and am using ODE45 to solve it, the code is
x0=[1;0];
tspan=[0:0.1:5];
[t,x]=ode45(@ex3,tspan,x0);
figure
plot(t,x)

답변 (1개)

kausalya lakshmanan
kausalya lakshmanan 2018년 5월 17일
use function [u dx] instead of function dx the value will save in workspace

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by