Array indices must be positive integers or logical values.
Afficher commentaires plus anciens
hFig = figure
clc;
v = 2.0;u = 2.0;
K = 8.617e-5;
trig = sin(4)*cos(4);
p = 2.7; t = 2.0; e = 1.6022e-19;
deltag = 0.0156; deltaxi = 0.0204;
n=[0.00 0.20 0.50 1.00];
T = linspace(0,700, 30); % However many you want.
delta1 = deltag./(K.*T); delta2 = deltaxi./(K.*T);
B0xi = besseli(0,delta2); B1xi = besseli(1, delta2);
B0g = besseli(0, delta1); B1g = besseli(1, delta1);
q = ((K^2).*T)./(e^2); g = p./(K.*T);
a = (B0g./B1g)- (2./delta1);
b = (1 - ((3./delta1).*(B0g./B1g)) + 6./(delta1.^2));
c = (1 - ((B1xi./B0xi).*(1./delta2)));
legendStrings = cell(length(n), 1);
for k1 = 1:length(n)
thisN = n(k1);
sigma = ((1i.*u-1-v.^2)./(v.^2-u.^2 +1-2i.*u)).*(1./(v.^2 +1));
sigmapri = thisN * ((1i.*u-1-v.^2)./((1+(thisN.*t)).^2 +v.^2).*(v.^2-u.^2 +1-2i.*u)).*(((B0g./B1g).*exp(0.9i.*pi))-(v./(v.^2 +1)));
w = sigma + sigmapri;
m = (w.*q.*trig((g.^2)-(2.*delta1.*g.*a)-(2.*delta2.*g.*(B1xi./B0xi))+((delta1.^2).*b)+(delta1.*delta2.*a.*(B1xi./B0xi))+((delta2.^2).*c)));
legendStrings{k1} = sprintf('n = %.2f', thisN);
plot(T, real(m), '.-', 'LineWidth', 2, 'MarkerSize', 15);
hold on;
drawnow;
end
grid on;
fontSize = 20;
xlabel('T(K)', 'FontSize', fontSize)
ylabel('\chi_\gamma', 'FontSize', fontSize)
title('\chi_\gamma vs. Temp(K)', 'FontSize', fontSize)
legend(legendStrings, 'Location', 'northeast');
% Maximize the figure window.
hFig.WindowState = 'maximized';
Réponse acceptée
Plus de réponses (1)
Steven Lord
le 4 Avr 2020
m = (w.*q.*trig((g.^2)-(2.*delta1.*g.*a)-(2.*delta2.*g.*(B1xi./B0xi))+...
((delta1.^2).*b)+(delta1.*delta2.*a.*(B1xi./B0xi))+((delta2.^2).*c)));
You meant to multiply trig by the expression that follows it, not to use that expression to index into the (scalar) trig variable, right?
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!