How to store a intermediate variable from ode45 function to the Workspace as a vector
Show older comments
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]);
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!