I am trying to plot freq vs max(x)/max(y) values for the following data. But I am having an error as shown below.Can anyone help me with this.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
% file 1
for f=1:100
t = [0:0.01:2];
x0 = [0;0];
[t,x]=ode23('for1', t, x0);
[val,idx] = max(x) ;
fr(f)=f;
val(f)=val;
hold on
end
plot(fr,val/0.001,'*r')
%file 2
function f = for1(t,x)
c = 376.9900;
k = 7.1061e+05;
Y = 0.001;
f=zeros (2,1);
f(1) = x(2);
f(2) = -(c*x(2)/5)-(k.*x(1)/5)+((k/5).*Y.*sin(2.*pi.*f.*t))+( (c/5).*Y*2*pi.*f.*cos(2*pi.*f.*t));
end
Unable to perform assignment because the
left and right sides have a different
number of elements.
%ERROR
Error in for1 (line 8)
f(2) =
-(c*x(2)/5)-(k.*x(1)/5)+((k/5).*Y.*sin(2.*pi.*f.*t))+(
(c/5).*Y*2*pi.*f.*cos(2*pi.*f.*t));
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I
sets args{1} to yp0.
Error in ode23 (line 114)
odearguments(FcnHandlesUsed,
solver_name, ode, tspan, y0, options,
varargin);
Error in test1 (line 4)
[t,x]=ode23('for1', t, x0);
Required Output:
3 comentarios
Jesus Sanchez
el 15 de Dic. de 2019
I am sorry, I have never worked with ode23 before, so I am not sure how to help you further :(. From the error message, it seems that tspan must be a vector, so you will have to work under this assumption and modify your function consequently.
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!