I can't graph

2 views (last 30 days)
Yordani
Yordani on 4 Jan 2023
Commented: Walter Roberson on 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)

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!