How can I output a 2 column matrix from a function?
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!