Having this problem second time can anyone help?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by