for loop for non integer values
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all, Can you help me please with this code that I stuck!? I want to solve a fifth order polynomial for values of time(t) between (1:0.3.10) I use the code below, but all the time the value of piks the integer i values ( 1,2,3,4,5,6,7,8,9,10) and it does not calculate E for non integer values(0.3, 0.6, 0.9 ...) Where is the problem? Could you please help me?
clc
clear all
syms a3 a4 a5 t
x=a3*t.^3+a4*t.^4+a5*t.^5;
for i=1:0.5:10;
x1=subs(x,t,i);
x_p=subs(diff(x,t),t,i);
x_pp=subs(diff(x,t,2),t,i);
eqns=[x1==75, x_p==0, x_pp==0];
S=solve(eqns,[a3,a4,a5]);
a3_5=S.a3;
a4_5=S.a4;
a5_5=S.a5;
L=subs(x,[a3,a4,a5],[a3_5,a4_5,a5_5]);
L_p=diff(L);
L_pp=diff(L,2);
J=0.000011*L_pp.^2;
E(i,:)=vpa(int(J,[0,i]))
digits(4);
end
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Systems of Nonlinear Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!