Having this problem second time can anyone help?

1 回表示 (過去 30 日間)
Demberel
Demberel 2022 年 12 月 16 日
編集済み: Arif Hoq 2022 年 12 月 16 日
a=[1.1];
b=[0.09];
x(1)=1.16; x(2)=1.32; x(3)=1.47; x(4)=1.65; x(5)=1.93;
for i=1:5
y(i)=(log(x.^2-1))./log(a.*x.^2-b);
end
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
y

回答 (1 件)

Arif Hoq
Arif Hoq 2022 年 12 月 16 日
編集済み: Arif Hoq 2022 年 12 月 16 日
a=1.1;
b=0.09;
% x(1)=1.16;
% x(2)=1.32;
% x(3)=1.47;
% x(4)=1.65;
% x(5)=1.93;
x=[1.16;1.32;1.47;1.65;1.93];
% y=(log(x.^2-1))./log(a.*x.^2-b)
for i=1:size(x,1)
y(i)=(log(x(i).^2-1))./log(a.*x(i).^2-b);
end
y
y = 1×5
-3.2253 -0.4944 0.1804 0.5099 0.7221
%% without loop
a=1.1;
b=0.09;
x=[1.16;1.32;1.47;1.65;1.93];
y=log(x.^2-1)./log(a.*x.^2-b)
y = 5×1
-3.2253 -0.4944 0.1804 0.5099 0.7221

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by