Retrieve vector within function file
이전 댓글 표시
x = 10';
tspan = [0 10];
[t,x]= ode45(@fun,tspan,x);
[~, u] = fun(t.',x.');
figure(1)
plot(t,u,'-k','Linewidth',1.5);
and function file is
function [dot,u] = fun(~,x)
k = 1;
p = 10;
x = x(1);
u = (-k.*x + x.^3 - p.*x^2) ./ x;
xdot = -x.^3 + p.*x.^2 + x.*u;
dot = xdot';
When I try to plot t with u, I am not getting a plot because input u is not getting saved as vector.
Is there any way that u can be saved as a vector here?
Thanks
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Data Acquisition에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
