Azzera filtri
Azzera filtri

Definite Integrals in for-loop

2 visualizzazioni (ultimi 30 giorni)
T
T il 9 Set 2016
Commentato: T il 22 Set 2016
I'm trying to setup up this loop. But before I do that I need to declare the functions:
n_grid = 20; % Size of rid
Ms = [];
Js = [];
Ns = [];
Es = [];
J = linspace(0,1,1000);
kappa = 2.*sinh(2*J)./(cosh(2*J)).^2;
kappam = 2*(tanh(2*J)).^2-1;
z = exp(-2*J);
K1 = int(sqrt(1- kappam.^2 * sin(phi).^2), phi= 0.. pi/2)
% Calculating Energy & Magnetisation as a function of interaction strength
E = -J.*(coth(2*J)).*(1+(2/pi)*kappam.*K1(kappam));
An error for K1 shows as follows:
Undefined function 'K1' for input arguments of type 'char'.
Error in ising (line 12)
K1 := int(sqrt(1- kappam.^2 * sin(phi).^2), phi= 0.. pi/2)
What's wrong with my syntax?

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 9 Set 2016
Modificato: Andrei Bobrov il 9 Set 2016
Please try code below
J = linspace(0,1,1000);
kappam = 2*(tanh(2*J)).^2-1;
f = @(phi)sqrt(1- kappam.^2 * sin(phi).^2);
K1 = integral(f,0,pi/2,'ArrayValued',true);
  11 Commenti
Walter Roberson
Walter Roberson il 22 Set 2016
I had no problems with the software once I had done what I indicated above needed to be done.
You might notice that the code in ising.m is spaced oddly. That is because I copied it directly from the pdf and did not bother to change the spacing.
T
T il 22 Set 2016
Strange. Those files work thanks.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Oil, Gas & Petrochemical 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!

Translated by