I am having this error, could you help?

1 回表示 (過去 30 日間)
Demberel
Demberel 2022 年 12 月 7 日
回答済み: Voss 2022 年 12 月 7 日
a=[1.6];
b=[0];
x(1)=1.28; x(2)=1.36; x(3)=2.47; x(4)=3.68; x(5)=4.56;
for i=1:5
y(i)=a.^(x.^2-1)-log(x.^2-1)+(x.^2).^(1/3);
end
y

回答 (2 件)

Arif Hoq
Arif Hoq 2022 年 12 月 7 日
編集済み: Arif Hoq 2022 年 12 月 7 日
try this:
a=1.6;
b=0;
% x(1)=1.28;
% x(2)=1.36;
% x(3)=2.47;
% x(4)=3.68;
% x(5)=4.56;
x=[1.28;1.36;2.47;3.68;4.56];
for i=1:size(x,1)
y(i)=a^(x(i)^2-1)-log(x(i)^2-1)+(x(i)^2).^(1/3);
end
y
y = 1×5
1.0e+04 * 0.0003 0.0003 0.0011 0.0363 1.0971
  1 件のコメント
Askic V
Askic V 2022 年 12 月 7 日
Even better, use
for iii=1:numel(x)
This way if you add more/remove elements in vector x, you won't have to change te limit in the for loop.

サインインしてコメントする。


Voss
Voss 2022 年 12 月 7 日
a=1.6;
b=0;
x=[1.28 1.36 2.47 3.68 4.56];
y=a.^(x.^2-1)-log(x.^2-1)+(x.^2).^(1/3);
y
y = 1×5
1.0e+04 * 0.0003 0.0003 0.0011 0.0363 1.0971

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by