Matlab Indexing Error A(I) = B

Hi. I am new to matlab and have this error I can't quite figure out. Here's the code:
clear all
clc
h = 12.5;
l = 12;
L = 16;
m = pi/10:pi/10:2*pi;
n = length(m);
d_plot = zeros(1,n);
for i = 1:n
d = acos((L*cos(m) - h)/l);
d_plot(i) = d;
end
The error says: In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> test2 at 12 d_plot(i) = d;
Will appreciate it if someone could point out the error for me. Thanks in advance

1 Comment

Each time through the "for i" loop, you are calculating exactly the same thing. Why is that?

Answers (0)

This question is closed.

Tags

Asked:

on 4 Apr 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!