How to correct matrix dimension disagree error

1 visualización (últimos 30 días)
Samuel Suakye
Samuel Suakye el 28 de Mzo. de 2020
Comentada: Samuel Suakye el 16 de Abr. de 2020
figure
clear;
clc;
v = 1.0;
n=[0.00 0.10 0.12 0.18];
u = linspace(0,2);
%%
for i = 1:length(n)
sigma = ((1i.*u-1-v.^2)./(v.^2-u.^2 +1-2i.*u)).*(1./(v.^2 +1));
sigmapri = n*((1i.*u-1-v.^2)./((1+n).^2 +v.^2).*(v.^2-u.^2 +1-2i.*u)).*(1-(v./(v.^2 +1)));
w = sigma + sigmapri;
plot(u, real(w))
end
%%
xlabel('\omega*\tau')
ylabel('\sigma(\omega)/\sigma_o')
  4 comentarios
Samuel Suakye
Samuel Suakye el 28 de Mzo. de 2020
I want to plot both the real part and the imaginary part separately
Samuel Suakye
Samuel Suakye el 28 de Mzo. de 2020
I want to plot a graph when n=0, n=0.10, n=0.12, n=0.18 using iteration on the same xy-plane

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 28 de Mzo. de 2020
I think you're looking for this:
hFig = figure
clc;
v = 1.0;
n=[0.00 0.10 0.12 0.18];
u = linspace(0,2, 30); % However many you want.
legendStrings = cell(length(n), 1);
for k1 = 1:length(n)
thisN = n(k1);
for k2 = 1 : length(u)
thisU = u(k2);
sigma = ((1i.*thisU-1-v.^2)./(v.^2-thisU.^2 +1-2i.*thisU)).*(1./(v.^2 +1));
sigmapri = thisN * ((1i.*thisU-1-v.^2)./((1+thisN).^2 +v.^2).*(v.^2-thisU.^2 +1-2i.*thisU)).*(1-(v./(v.^2 +1)));
w(k2) = sigma + sigmapri;
end
legendStrings{k1} = sprintf('n = %.2f', thisN);
plot(u, real(w), '.-', 'LineWidth', 2, 'MarkerSize', 15);
hold on;
drawnow;
end
grid on;
fontSize = 20;
xlabel('\omega*\tau', 'FontSize', fontSize)
ylabel('\sigma(\omega)/\sigma_o', 'FontSize', fontSize)
title('\sigma(\omega)/\sigma_o vs. \omega*\tau', 'FontSize', fontSize)
legend(legendStrings, 'Location', 'northwest');
% Maximize the figure window.
hFig.WindowState = 'maximized';
  4 comentarios
Samuel Suakye
Samuel Suakye el 16 de Abr. de 2020
% A graph of j_z/j_o = j vrs beta1 (dimensionless amplitude)
% On 12-04-2020
hFig = figure
clc;
b = 0.142e-9; gammao = 3.0; m = 101;
hbar = 1; e = -1;
K = 8.617e-16; T = 287.5;
a = ((3*b)/(2*hbar)); Pz = ((2*pi*hbar)/(3*b));
beta2 = 1; beta1 = linspace(0,10, 30); % However many you want.
Wcnzz = sqrt(3);
jo = ((8*e*Wcnzz*gammao)/(3*hbar*m*b));
%%
syms q s
B1 = q.*beta1; B2 = q.*beta2; v = ((pi.*s)./m); h = (a.*Pz);
z = (2.*(pi.^2).*s.*sqrt(3).*(a./(2*pi)));
Eqszz = (a./(2*pi)).*((1+(4.*cos(h).*cos(v))+(4.*((cos(v)).^2))).^0.5);
Fqszz = ((a.^2).*m)./((z.*((1+(4.*cos(h).*cos(v))+(4.*((cos(v)).^2))).^0.5))./(K.*T));
J1 = besselj(0,B1); J2 = besselj(0,B2);
J = q.*Fqszz.*Eqszz.*J1.*J2;
X = symsum(J,s,1,m);
jz = symsum(X,q,1,inf);
j = jz./jo;
fplot(beta1, j, 'r-', 'LineWidth', 2 );
drawnow;
grid on;
fontSize = 20;
xlabel('\beta_1', 'FontSize', fontSize)
ylabel('j_z/j_o', 'FontSize', fontSize)
hold on
%%
b = 0.142e-9; gammao = 3.0; m = 101;
hbar = 1; e = -1;
K = 8.617e-16; T = 287.5;
a = ((3*b)/(2*hbar)); Pz = ((2*pi*hbar)/(3*b));
beta2 = 1; beta1 = linspace(0,10, 30); % However many you want.
Wcnac = 1; t = sqrt(3); n = 1e-9;
jo = ((8*e*Wcnac*gammao)/(3*hbar*m*b));
%%
syms q s
B1 = q.*beta1; B2 = q.*beta2; u = ((a.*Pz)./t); g = ((pi.*s.*t)./n);
y = (2.*(pi.^2).*s.*t);
Eqsac = ((1+(4.*cos(g).*cos(u))+(4.*((cos(u)).^2))).^0.5);
Fqsac = ((a.^2).*n)./((y.*((1+(4.*cos(g).*cos(u))+(4.*((cos(u)).^2))).^0.5))./(K.*T));
J1 = besselj(0,B1); J2 = besselj(0,B2);
J = q.*Fqsac.*Eqsac.*J1.*J2;
X1 = symsum(J,s,1,m);
jz = symsum(X1,q,1,inf);
j = jz./jo;
fplot(beta1, j, 'b-', 'LineWidth', 2);
drawnow;
grid on;
fontSize = 20;
xlabel('\beta_1', 'FontSize', fontSize)
ylabel('j_z/j_o', 'FontSize', fontSize)
title('j_x/j_o vs. \beta_1', 'FontSize', fontSize)
legend('zigzig CNs','armchair CNs','Location','Best');
% Maximize the figure window.
hFig.WindowState = 'maximized';
Samuel Suakye
Samuel Suakye el 16 de Abr. de 2020
Please help me solve this problem, it is a double summation and can't tell whether am right because for two days running and still no results. Thanks in advance

Iniciar sesión para comentar.

Más respuestas (1)

the cyclist
the cyclist el 28 de Mzo. de 2020
You are effectively trying to do this operation in your code:
n * u
where n is a 1x4 matrix, and u is a 1x100 matrix.
That won't work, as either a matrix multiplication or as an element-by-element multiplication. What do you expect from that?
  1 comentario
Samuel Suakye
Samuel Suakye el 28 de Mzo. de 2020
I want to plot a graph when n=0, n=0.10, n=0.12, n=0.18 using iteration on the same xy-plane

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by