Looping of more than one first order equations in in function file that can be updated for different value variable parameter

1 次查看(过去 30 天)
I want to feed component of vector C (1by20) one by for each loop of system first orde differential equation in order to numerically integrating the whole (320by1) equations simultaneously. i am not able to loop it currectly kindly help me.
function [f]=Loop_stiffness_nonlin12(t,y,C,w,phia,phid,E1,lmda1,m0,e,N)
%% sinusoidal force
% W=2*N*pi/60;
%
% p1=m0*e*(W)^2*sin(W*t);
%
% p1=p1/10;
f= zeros(320,1);
for j=1:16:305
f(j)=y(1+j);
f(1+j)= -w(1)^2*y(j)-lmda1*y(1+j)-C(1,i)*phid(1)*(phid(1)*y(j)-y(2+j))^3;
f(4+j)=y(5+j);
f(5+j)= -w(2)^2*y(4+j)-lmda1*y(5+j)-C(1,i)*phid(2)*((phid(1)*y(j)+phid(2)*y(4+j))-y(2+j))^3;
f(6+j)=y(7+j);
f(7+j)= -w(3)^2*y(6+j)-lmda1*y(7+j)-C(1,i)*phid(3)*((phid(1)*y(j)+phid(2)*y(4+j);
f(8+j)=y(9+j);
f(9+j)= -w(4)^2*y(8+j)-lmda1*y(9+j)-C(1,i)*phid(4)*((phid(1)*y(j);
f(10+j)=y(11+j);
f(11+j)= -w(5)^2*y(10+j)-lmda1*y(11+j)-C(1,i)*phid(5)*((phid(1)*y(j)+phid(2)*y(4+j));
f(2+j)= y(3+j);
f(3+j)= (C(1,i)/E1)*((phid(1)*y(j)+phid(2)*y(4+j)+phid(3)*y(6+j)+phid(4)*y(8+j)+phid(5)*y(10+j))-y(2+j))^3+(lmda1/E1)*((phid(1)*y(1+j)+phid(2)*y(5+j)
end
end
end

采纳的回答

darova
darova 2021-4-6
See this example
f = @(t,x,a) [x(2); x(1)-a*sin(x(1))];
a = rand(10,1); % parameter
cmap = jet(10);
for i = 1:length(a)
[t,x] = ode45(f,[0 2],[1 1],[],a(i));
line(t,x(:,1),'color',cmap(i,:))
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by