How to store a intermediate variable from ode45 function to the Workspace as a vector
显示 更早的评论
Having a system of two odes
I put the odes in a function and the script to solve the given function
I would like to store ALL "n" values in the Workspace. If I use "global n", I can see just one value of the n (the last one). Could you please help me to find a way for that case?
Thanks in advance
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dx=funx1x2(t,x)
global n
S=250;
CC=2.35;
DD=0.65;
%State variables
k=x(1);
q=x(2);
L=k*S*CC;
D=q*S*DD;
n=sqrt(L^2+D^2)
%Equations of motion
dx=zeros(2,1);
dx(1)=q;
dx(2)=0.5*t*k;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Solver
clc; clear all;
global n
[t x]= ode45(@funx1x2,[0 5],[0 0.5]);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!