MATLAB Answers

Converting symbolic function to symbolic formula in order to use FSOLVE

1 view (last 30 days)
Meva
Meva on 20 Aug 2016
Commented: Meva on 21 Aug 2016
Hi, I need to convert symbolic functions integral_result_1 and integral_result_2 to symbolic formula in order to use fsolve for my 2 by 2 nonlinear system.
function F=torder1(x)
% clear all; clc; close all;
x_1=[0:0.01:1];
b=0.6;
T = [0:0.01:1]; % this is time vector
clear x_1;
syms x_1 h theta
kappa = 1;
f_11(x_1,h,theta) = 1-( (h+(x_1-b)*theta)^2/(h+(x_1-b)*theta-1*x_1*(1-x_1))^2 );
f_21(x_1,h,theta) = (x_1-b)/2*( 1-( (h+(1-b)*theta)^2/(h+(x_1-b)*theta-x_1*(1-x_1))^2 ));
fint_1 = int(f_11, x_1);
fint_2 = int(f_21, x_1);
x_1=1;
upper_1=subs(fint_1);
upper_2=subs(fint_2);
clear x_1;
x_1=0;
lower_1=subs(fint_1);
lower_2=subs(fint_2);
clear x_1;
integral_result_1old=upper_1-lower_1;
integral_result_2old=upper_2-lower_2;
h0 = kappa *b*(1-b);
theta0 = kappa*(1-2*b);
integral_result_1 = subs(integral_result_1old, {h, theta}, {x(1), x(2)})
integral_result_2 = subs(integral_result_2old, {h, theta}, {x(1), x(2)})
%
F = [x(1) - integral_result_1 -h0;
x(2) - integral_result_2 - theta0]
Please see my old question for further info.
Thanks for any help.

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 21 Aug 2016
Change
f_11(x_1,h,theta) = 1-( (h+(x_1-b)*theta)^2/(h+(x_1-b)*theta-1*x_1*(1-x_1))^2 );
f_21(x_1,h,theta) = (x_1-b)/2*( 1-( (h+(1-b)*theta)^2/(h+(x_1-b)*theta-x_1*(1-x_1))^2 ));
to
f_11 = 1-( (h+(x_1-b)*theta)^2/(h+(x_1-b)*theta-1*x_1*(1-x_1))^2 );
f_21 = (x_1-b)/2*( 1-( (h+(1-b)*theta)^2/(h+(x_1-b)*theta-x_1*(1-x_1))^2 ));
Change
F = [x(1) - integral_result_1 -h0;
x(2) - integral_result_2 - theta0]
to
F = [double(x(1) - integral_result_1 -h0);
double(x(2) - integral_result_2 - theta0)];

More Answers (0)

Sign in to answer this question.


Translated by