Effacer les filtres
Effacer les filtres

syntax of fsolve

2 vues (au cours des 30 derniers jours)
Ankit
Ankit le 13 Juin 2012
I am having some trouble with the fsolve syntax. In the code below value of m and x_length are known and constants. variables are B0 and A0 which are discretized. p is time and q is length. this code below is for a particular time . Please help
l = 1:m
q = 2:x_length;
F(1: (x_length-1) ) =...
-[B0(p+1,q) - B0(p,q)] + const_a*[B0(p+1,q+1) - 2*B0(p+1,q) + B0(p+1,q-1) + B0(p,q+1) - 2*B0(p,q) + B0(p,q-1)]- [[const_b*[B0(p+1,q)+B0(p,q)]].*[A0(p+1,q)+A0(p,q)]];
F(((x_length-1)*(m+2)+1) :(x_length-1)*(m+3) ) =...
-[A0(p+1,q)- A0(p,q)] + const_a*[A0(p+1,q+1) - 2*A0(p+1,q) + A0(p+1,q-1) + A0(p,q+1) - 2*A0(p,q) + A0(p,q-1)] - [[0.5*const_b*[A0(p+1,q)+ A0(p,q)]].*[sigmab(p+1,q)];
F(((x_length-1) + 1):(x_length-1)*(m+2) ) =...
-[B0(p+1,(x_length+1)*l+q)- B0(p,(x_length+1)*l+q)] + (const_a/m)*[B0(p+1,(x_length+1)*l+q+1) - 2*B0(p+1,(x_length+1)*l+q) + B0(p+1,(x_length+1)*l+q-1) + B0(p,(x_length+1)*l+q+1) - 2*B0(p,(x_length+1)*l+q) + B0(p,(x_length+1)*l+q-1)] - [[(0.5*const_b)*[A0(p+1,q)+ A0(p,q)]].*[B0(p+1,q)+ B0(p,q)]] + [[(const_b*2)*(A0(p+1,q) + A0(p,q))].*[sigmac(p+1,(x_length+1)*(l-1)+q)]]./[sigmab(p+1,q)] ;

Réponses (1)

Sargondjani
Sargondjani le 13 Juin 2012
you should write it as a function (in either anonymous function, function file or subfunction if your main program is also a function). Let's say you make a function file:
function [F]=my_fun(var1,var2,par1,par2,....)
F(1:x_length,1)=.....
F(x_length+1:....)=
end
Then if you want to solve for var1 and var2: f_obj=@(x)my_fun(x(1),x(2),par1,par2,...); %anonymous function fsolve(f_obj,x0)
with x0 containing two values (var1_0 and var2_0)

Catégories

En savoir plus sur Graphics Object Identification dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by