This type of error is seen

Unable to perform assignment because the indices on the left side are not compatible with the size of

the right side.

Error in diffra (line 46)

x(j)=linspace(0,0.025,101);

1 view (last 30 days)

Show older comments

Dear Sir/Madam,

I am not able to solve the given integration function. The screenshot of given is attached and the code is given below

Thank you

for j=1:100

x(j)=linspace(0,0.025,101);

R(j)=linspace(0,0.4,101);

f=0.025;

syms x

b(j)= int(R(j)-sqrt(R(j).^2-x(j).^2),0, f);

c(j)=sqrt((1/f)*b(j));

end

Jan
on 16 Dec 2021

This cannot work:

x(j) = linspace(0,0.025,101);

On the left is a scalar and on the right a vector with 101 elements.

Seeing only the invalid code does not clarify its intention. What is the purpose of the loop?

Jan
on 16 Dec 2021

Tesfaye Girma
on 16 Dec 2021

indeces should have to match in both side and be compatable as well

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

Start Hunting!