In an assignment A(I) = B, the number of elements in B and I must be the same. Error in odearguments (line 88) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 114) [neq, tspan, ntspan...
Show older comments
Alright. First of all I must say I'm quite new in the world of Matlab. I've done a few things but they were not a very big deal. At university we've been asked to represent the animation of a bouy depending on its density and size. Here's the two pieces of code I've written:
Here I define the differential equation that describes the general position of the object
function dy=fboya(t,y)
global g l rho0 rho_a radio;
v_boya=pi*radio^2*l;
m_boya= rho0*v_boya;
P=m_boya*g;
E=(rho_a*v_boya*g).*(z(1)<-l/2)+(rho_a*pi*radio^2.*(l/2-z(1))*g).*((-l/2<z(1))&(z(1)<l/2))+(0).*(l/2<z(1));
dz=zeros(2,1);
dz(1)=z(2);
dz(2)=(E-P)/m_boya;
And here is the rest of the code:
function [t,y]=mboya2(L,y_0,v_0,rho_agua,rho_0,tf,R)
global g l rho0 rho_a radio;
g=9.81; % gravedad
l=L;
rho0=rho_0; % densidad del objeto
rho_a=rho_agua; % densidad del agua
radio=R;
[t,y]=ode45(@fboya2,[0,tf],[y_0,v_0]);
y=y(:,1);
x=0;
close all;
figure;
set(gcf(),'Position',[300 250 800 300]);
subplot(1,2,1)
plot(x(1),y(1),'or',[0 x(1)],[0 y(1)],'b')
axis([-l,l,-l,l]);
axis square;
The thing is that I keep getting this error messages and I don't really undersand why is this happening.
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in fboya2 (line 14) dy(2)=(E-P)/m_boya; Error in odearguments (line 88) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in mboya2 (line 20) [t,y]=ode45(@fboya2,[0,tf],[y_0,v_0]);
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!