Undefined function 'x' for input arguments of type 'double'. Why does this flag that particular line and nowhere else? Is there a was to fix it?

1 回表示 (過去 30 日間)
%% Problem 3 Bungie Jump
mp=50;
k=10;
L=5;
g=9.81;
t0=0;
tf=45;
dt=0.02;
tspan=[t0:dt:tf];
% initial conditions
x0=2;
y0=0;
xdot0=0;
ydot0=0;
IC=[x0 xdot0 y0 ydot0];
[t,z]=ode45(@bungie_ode,tspan,IC,[],mp,k,L,g);
y=z(:,1);
y=z(:,3);
%figure
for i=L:length(t)
px=[0 x(i)];% Undefined function 'x' for input arguments of type 'double'. Error in ProgramName (line 81)px=[0 x(i)];
py=[0 y(i)];
qx=[10 x(i)];
qy=[0 y(i)];
plot
end

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 2 月 28 日
y=z(:,1);
y=z(:,3);
should be
x=z(:,1);
y=z(:,3);

カテゴリ

Help Center および File ExchangeBartlett についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by