How can I solve the equation of type h ? 6 unknows 6 equations

1 view (last 30 days)
Hello.
I would like to find out the result of the equation I mentioned below, type 'h'. For example A = 5h B = 0.65h C=.... How can I define the h. And I want to soln type h. Please answer immediately.
function fourthordereqn()
%We need solve the system forward mesh points.
%System want to solve y''(0)
%We must use 4+2=6 forward mesh points.
'f2(0)=A*f(0)+B*f(1)+C*f(2)+D*f(3)+E*f(4)+F*f(5)';
'Z0=A*f(0)';
'Z1=B*(f(0)+h*f1(0)+(h^2)/2*f2(0)+(h^3)/6*f3(0)+(h^4)/24*f4(0)+(h^5)/120*f5(0)+O*(h^6))';
'Z2=C*(f(0)+2*h*f1(0)+2*h^2*f2(0)+(2^3*h^3)/6*f3(0)+(2^4*h^4)/(4*3*2)*f4(0)+(2^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'Z3=D*(f(0)+3*h*f1(0)+(3^2*h^2)/2*f2(0)+(3^3*h^3)/6*f3(0)+(3^4*h^4)/(4*3*2)*f4(0)+(3^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'Z4=E*(f(0)+4*h*f1(0)+(4^2*h^2)/2*f2(0)+(4^3*h^3)/6*f3(0)+(4^4*h^4)/(4*3*2)*f4(0)+(4^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'Z5=F*(f(0)+5*h*f1(0)+(5^2*h^2)/2*f2(0)+(5^3*h^3)/6*f3(0)+(5^4*h^4)/(4*3*2)*f4(0)+(5^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'f(0)=0; f1(0)=0; f2(0)=1; f3(0)=0; f4(0)=0; f5(0)=0';
syms A B C D E F
%Write the equations for
%1st eqn f(0)=0
equation1=A+B+C+D+E+F;
%2nd eqn f1(0)=0
equation2=B*h+C*2*h+D*3*h+E*4*h+F*5*h;
%3rd eqn f2(0)=1
equation3=-1+(B*h^2/2)+(C*2*h^2)+(D*3^2*h^2/2)+(E*4^2*h^2/2)+(F*5^2*h^2/2);
%4th eqn f3(0)=0
equation4=(B*h^3/6)+(C*2^3*h^3/6)+(D*(3^3*h^3)/6)+(E*4^3*h^3/6)+(F*5^3*h^3/6);
%5th eqn f4(0)=0
equation5=(B*h^4/24)+(C*2^4*h^4/24)+(D*3^4*h^4/24)+(E*(4^4*h^4)/(4*3*2))+(F*(5^4*h^4)/(4*3*2));
%6th eqn f5(0)=0
equation6=(B*(h^5)/120)+(C*(2^5*h^5)/(5*4*3*2))+(D*(3^5*h^5)/(5*4*3*2))+(E*(4^5*h^5)/(5*4*3*2))+(F*(5^5*h^5)/(5*4*3*2));
sol.a=solve(equation1,equation2,equation3,equation4,equation5,equation6);
SOLN = structfun(@double,sol.a);
disp(SOLN);
but I'm having this problem.
Undefined function or variable 'h'

Answers (0)

Community Treasure Hunt

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

Start Hunting!