I can't graph

1 回表示 (過去 30 日間)
Yordani
Yordani 2023 年 1 月 4 日
コメント済み: Walter Roberson 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 Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by