Having this problem second time can anyone help?

1 view (last 30 days)
Demberel
Demberel on 16 Dec 2022
Edited: Arif Hoq on 16 Dec 2022
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

Answers (1)

Arif Hoq
Arif Hoq on 16 Dec 2022
Edited: Arif Hoq on 16 Dec 2022
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

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!