I can't graph

1 次查看(过去 30 天)
Yordani
Yordani 2023-1-4
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)

采纳的回答

Image Analyst
Image Analyst 2023-1-4
编辑:Image Analyst 2023-1-4
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 个评论
Walter Roberson
Walter Roberson 2023-1-4
It would not surprise me if the reference to e should be a reference to elec = 1.602e-19 instead.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by