Filter löschen
Filter löschen

I can't graph

1 Ansicht (letzte 30 Tage)
Yordani
Yordani am 4 Jan. 2023
Kommentiert: Walter Roberson am 4 Jan. 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)

Akzeptierte Antwort

Image Analyst
Image Analyst am 4 Jan. 2023
Bearbeitet: Image Analyst am 4 Jan. 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 Kommentar
Walter Roberson
Walter Roberson am 4 Jan. 2023
It would not surprise me if the reference to e should be a reference to elec = 1.602e-19 instead.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by