How can I output a 2 column matrix from a function?
Show older comments
I have a position expression and a velocity expression. I want to output a 2 column matrix with the data from t=0 to t=15. My t variable is t = linspace(0,15,100)' . Here is my code :
--------------------------
function [ x,xdot ] = finalproject( t )
% x represents position and xdot represents velocity
x = exp(-t./2).*(20.*cos(1.3229.*t)+22.6775.*sin(1.3229.*t));
xdot = exp(-t./2).*(20.*(-1./2.*cos(1.3229.*t) - 1.3229.*sin(1.3229.*t)) + 22.6775.*(-1./2.*sin(1.3229.*t) + 1.3229.*cos(1.3229.*t)));
end
------------------
In the Command Window, I know i need to have [.....] = finalproject(t) I can't seem to get it to work after trying various combinations of function output arguments and variables in the command window bracket.
Accepted Answer
More Answers (0)
Categories
Find more on Introduction to Installation and Licensing 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!