Borrar filtros
Borrar filtros

I can't graph

1 visualización (últimos 30 días)
Yordani
Yordani el 4 de En. de 2023
Comentada: Walter Roberson el 4 de En. de 2023
Hello! I am getting the following error in my code. Can someone help me solve it please. ?
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in Resistividad (line 20)
p(index) = (k(Ne)*e*u(index)).^-1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u1=68.5;
umax=1414;
u2=56.1;
Cr=9.2e16;
Cs=3.41e20;
alfa=0.711;
beta=1.98;
elec = 1.602e-19;
N1=1e17;
N2=1e17;
N3=1e21;
index=0;
k = N1:N2:N3;
for Ne = 1:length(k)
index = index + 1 ;
u(index) = u1 + ((umax-u1)/(1+(k(Ne)/Cr)^alfa)) - ((u2)/(1+(Cs/k(Ne))^beta));
p(index) = (k(Ne)*e*u(index)).^-1;
f(index) = k(Ne);
x(index) = f(index) ;
y(index) = p(index);
end
Unrecognized function or variable 'e'.
semilogx(x,y)

Respuesta aceptada

Image Analyst
Image Analyst el 4 de En. de 2023
Editada: Image Analyst el 4 de En. de 2023
You need to define e. If I define it as something, like 1, it works:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e=1;
u1=68.5;
umax=1414;
u2=56.1;
Cr=9.2e16;
Cs=3.41e20;
alfa=0.711;
beta=1.98;
elec = 1.602e-19;
N1=1e17;
N2=1e17;
N3=1e21;
index=0;
k = N1:N2:N3;
for Ne = 1:length(k)
index = index + 1 ;
u(index) = u1 + ((umax-u1)/(1+(k(Ne)/Cr)^alfa)) - ((u2)/(1+(Cs/k(Ne))^beta));
p(index) = (k(Ne)*e*u(index)).^-1;
f(index) = k(Ne);
x(index) = f(index) ;
y(index) = p(index);
end
semilogx(x,y)
  1 comentario
Walter Roberson
Walter Roberson el 4 de En. de 2023
It would not surprise me if the reference to e should be a reference to elec = 1.602e-19 instead.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by