ERROR: "Undefined function or method for double type" + "feval error" - Strange case/no plots

2 views (last 30 days)
Greetings,
My script only plots 1 out of 3 equations. It returns an error that stops the other two:
??? Error using ==> feval Undefined function or method 'F_CubeSat_AerotechG80' for input arguments of type 'double'.
Error in ==> odearguments at 98 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode15s at 227 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> F__CubeSat_rocket1 at 46 [t y] = ode15s('F__CubeSat_AerotechG80',t,yo); % Instruccion para utilizar _
This is the code for the main script
%-----------------------------Rocket1--------------------------------
% Este programa calcula la trayectoria vertical de un cohete.
% Considera efectos de fuerza de arrastre y de empuje. Se presume
% que el vuelo es perfectamente vertical y no hay velocidad de viento.
% La densidad del aire y la aceleracion de la gravedad se presumen
% constantes
%--------------------------29/01/2013---------------------------------
clc
clear all
close all
global T rho Cd Af g mo mdot tb tf dt Dt
load(('F__CubeSat_AerotechG80.txt')) %Descarga el empuje del motor
[nr nc] = size(F__CubeSat_AerotechG80);
n = nr*nc; %Cantidad total de datos en archivo del motor
tf = 0.03125*(n-1); %Tiempo final de vuelo
Dt = 0.03125; %Incremento de tiempo original datos del motor
tt = (0:Dt:tf);
T = F__CubeSat_AerotechG80';
dt = 0.001; %Incremento de tiempo deseado para solucion
t = (0:dt:tf);
[Nr Nc] = size(t);
%--------------------Grafico fuerza de empuje--------------------------
figure;
plot(tt,T); grid on;
xlabel('tiempo [seg]');
ylabel('Empuje [N]');
%------------------------------Datos-----------------------------------
rho = 1.2041; % Densidad del aire [kg/m^3]
Cd = 0.2; % Coeficiente de arrastre
Af = 2.026e-3; % Area frontal del cohete [m^2]
g = 9.81; % Aceleracion gravedad [m/s^2]
mo = 0.5; % Masa inicial del cohete [kg]
tb = 1.5; % Tiempo de combustion del motor [seg]
mdot = 0.0417; % Flujo masico de combustible[kg/s]
yo = [0;0]; % Condiciones iniciales [posicion y velocidad]
%--------------------------Computo de posicion--------------------------
[t y] = ode15s('F__CubeSat_AerotechG80',t,yo); % Instruccion para utilizar
% la libreria de ecuaciones diferenciales
%----------------------Grafico de posicion vs tiempo--------------------
figure;
plot(t,y(:,1)); grid on;
xlabel('Tiempo [seg]');
ylabel('Altura [m]');
%---------------------Grafico de velocidad vs tiempo--------------------
figure;
plot(t,y(:,2)); grid on;
xlabel('Tiempo [seg]');
ylabel('Velocidad [m]');
%---------------Computo y grafico de aceleracion vs tiempo--------------
deltav = diff(y(:,2));
deltat = diff(t);
a = deltav./deltat;
figure;
plot (t(1:Nc-1),a); grid on;
xlabel('Tiempo [seg]');
ylabel('Aceleracion [m/s^2]');
This is the code for the supporting script file:
function ydot=F__CubeSat_rocket(t,y)
global T rho Cd Af g mo mdot tb tf dt Dt
dt = 0.001;
if t<=tb
m = mo-mdot*t;
else
m = mo-mdot*tb;
end
ty = (0:Dt:tf);
Tb = interp1(ty,T,t);
ydot=[y(2);((Tb-0.5*rho*Cd*Af*y(2)^2)/m)-g];
I have no idea how to resolve it. It should be working; I've even thought it's a MatLab version issue. I will thank you from the bottom of my heart if you can explain to me what the error here is.
All thanks in advance.
-Moya

Accepted Answer

Mischa Kim
Mischa Kim on 9 Mar 2014
Edited: Mischa Kim on 9 Mar 2014
It looks like your ODE function is called F__CubeSat_rocket:
function ydot = F__CubeSat_rocket(t,y)
However, you are calling ode15s with F__CubeSat_AerotechG80
[t y] = ode15s('F__CubeSat_AerotechG80',t,yo);
I assume you want
[t y] = ode15s('F__CubeSat_rocket',t,yo);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!